-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into matteogp/builder-contribute/source-navan
- Loading branch information
Showing
145 changed files
with
1,965 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
airbyte-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/load/data/Transformations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.load.data | ||
|
||
import java.text.Normalizer | ||
import java.util.regex.Pattern | ||
|
||
class Transformations { | ||
companion object { | ||
private const val S3_SAFE_CHARACTERS = "\\p{Alnum}/!_.*')(" | ||
private const val S3_SPECIAL_CHARACTERS = "&$@=;:+,?-" | ||
private val S3_CHARACTER_PATTERN = | ||
"[^${S3_SAFE_CHARACTERS}${Pattern.quote(S3_SPECIAL_CHARACTERS)}]" | ||
const val NON_ALPHANUMERIC_AND_UNDERSCORE_PATTERN: String = "[^\\p{Alnum}_]" | ||
|
||
fun toS3SafeCharacters(input: String): String { | ||
return Normalizer.normalize(input, Normalizer.Form.NFKD) | ||
.replace( | ||
"\\p{M}".toRegex(), | ||
"", | ||
) // P{M} matches a code point that is not a combining mark (unicode) | ||
.replace(S3_CHARACTER_PATTERN.toRegex(), "_") | ||
} | ||
|
||
fun toAlphanumericAndUnderscore(s: String): String { | ||
return Normalizer.normalize(s, Normalizer.Form.NFKD) | ||
.replace( | ||
"\\p{M}".toRegex(), | ||
"" | ||
) // P{M} matches a code point that is not a combining mark (unicode) | ||
.replace("\\s+".toRegex(), "_") | ||
.replace(NON_ALPHANUMERIC_AND_UNDERSCORE_PATTERN.toRegex(), "_") | ||
} | ||
|
||
fun toAvroSafeNamespace(namespace: String): String { | ||
val tokens = | ||
namespace.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() | ||
return tokens | ||
.map { name: String -> toAlphanumericAndUnderscore(name) } | ||
.joinToString(separator = ".") | ||
} | ||
|
||
fun toAvroSafeName(name: String) = toAlphanumericAndUnderscore(name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.