-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalization - BigQuery use
json_extract_string_array
for array of…
… simple types (#13289) Signed-off-by: Sergey Chvalyuk <[email protected]> Co-authored-by: andrii.leonets <[email protected]> Co-authored-by: Andrii Leonets <[email protected]>
- Loading branch information
1 parent
5df20b7
commit 2daaf5b
Showing
11 changed files
with
131 additions
and
27 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
70 changes: 70 additions & 0 deletions
70
airbyte-db/db-lib/src/main/java/io/airbyte/db/util/JsonUtil.java
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,70 @@ | ||
package io.airbyte.db.util; | ||
|
||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import com.fasterxml.jackson.databind.node.ContainerNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import java.math.BigDecimal; | ||
|
||
public class JsonUtil { | ||
|
||
public static void putBooleanValueIntoJson(final ContainerNode<?> node, final boolean value, final String fieldName) { | ||
if (node instanceof ArrayNode) { | ||
((ArrayNode) node).add(value); | ||
} else if (node instanceof ObjectNode) { | ||
((ObjectNode) node).put(fieldName, value); | ||
} else { | ||
throw new RuntimeException("Can't populate the node type : " + node.getClass().getName()); | ||
} | ||
} | ||
|
||
public static void putLongValueIntoJson(final ContainerNode<?> node, final long value, final String fieldName) { | ||
if (node instanceof ArrayNode) { | ||
((ArrayNode) node).add(value); | ||
} else if (node instanceof ObjectNode) { | ||
((ObjectNode) node).put(fieldName, value); | ||
} else { | ||
throw new RuntimeException("Can't populate the node type : " + node.getClass().getName()); | ||
} | ||
} | ||
|
||
public static void putDoubleValueIntoJson(final ContainerNode<?> node, final double value, final String fieldName) { | ||
if (node instanceof ArrayNode) { | ||
((ArrayNode) node).add(value); | ||
} else if (node instanceof ObjectNode) { | ||
((ObjectNode) node).put(fieldName, value); | ||
} else { | ||
throw new RuntimeException("Can't populate the node type : " + node.getClass().getName()); | ||
} | ||
} | ||
|
||
public static void putBigDecimalValueIntoJson(final ContainerNode<?> node, final BigDecimal value, final String fieldName) { | ||
if (node instanceof ArrayNode) { | ||
((ArrayNode) node).add(value); | ||
} else if (node instanceof ObjectNode) { | ||
((ObjectNode) node).put(fieldName, value); | ||
} else { | ||
throw new RuntimeException("Can't populate the node type : " + node.getClass().getName()); | ||
} | ||
} | ||
|
||
public static void putStringValueIntoJson(final ContainerNode<?> node, final String value, final String fieldName) { | ||
if (node instanceof ArrayNode) { | ||
((ArrayNode) node).add(value); | ||
} else if (node instanceof ObjectNode) { | ||
((ObjectNode) node).put(fieldName, value); | ||
} else { | ||
throw new RuntimeException("Can't populate the node type : " + node.getClass().getName()); | ||
} | ||
} | ||
|
||
public static void putBytesValueIntoJson(final ContainerNode<?> node, final byte[] value, final String fieldName) { | ||
if (node instanceof ArrayNode) { | ||
((ArrayNode) node).add(value); | ||
} else if (node instanceof ObjectNode) { | ||
((ObjectNode) node).put(fieldName, value); | ||
} else { | ||
throw new RuntimeException("Can't populate the node type : " + node.getClass().getName()); | ||
} | ||
} | ||
|
||
} |
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