Add nullable option support into fromJson [DATABEAM-39]#23
Add nullable option support into fromJson [DATABEAM-39]#23ilya-kozyrev merged 3 commits intoProtegrityIntegrationTemplatefrom
Conversation
v2/common/src/main/java/com/google/cloud/teleport/v2/utils/BeamSchemaUtils.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
|
|
||
| private static boolean getOptionalBoolean(JsonNode node, String key, boolean defaultValue) { |
There was a problem hiding this comment.
not sure that I understand naming. You planning to use this method to parse types of fields in the schema?
if not let's name it something like "isOptionalField"
There was a problem hiding this comment.
Yes, this method is for reading a boolean field in JSON, which might not exist
There was a problem hiding this comment.
any other cases where we need to read boolean values from json?
There was a problem hiding this comment.
At this moment there are no other cases.
There was a problem hiding this comment.
Let's keep it, I think this way the code looks a bit more clear
v2/common/src/main/java/com/google/cloud/teleport/v2/utils/BeamSchemaUtils.java
Outdated
Show resolved
Hide resolved
| String jsonString = "[{\"name\": \"nullableField\", \"type\": \"STRING\", \"nullable\": true},{\"name\": \"nonNullableField\", \"type\": \"STRING\", \"nullable\": false},{\"name\": \"defaultNullableValueField\", \"type\": \"STRING\"}]"; | ||
| Schema schema = BeamSchemaUtils.fromJson(jsonString); | ||
| assertEquals(3, schema.getFieldCount()); | ||
| assertEquals("nullableField", schema.getField(0).getName()); |
There was a problem hiding this comment.
Could be not repeatable, because order of fields not guarantee after deserialization
v2/common/src/main/java/com/google/cloud/teleport/v2/utils/BeamSchemaUtils.java
Outdated
Show resolved
Hide resolved
v2/common/src/test/java/com/google/cloud/teleport/v2/utils/BeamSchemaUtilsTest.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
|
|
||
| private static boolean getOptionalBoolean(JsonNode node, String key, boolean defaultValue) { |
There was a problem hiding this comment.
Let's keep it, I think this way the code looks a bit more clear
* Type handler (#10) * Added Type Handler for Cassandra * Added UT * PR review comments fixes (#13) * Refectored the code * Handle Minor fixes * Casting fixes PR review comments fixed * Type handler review cm (#14) * updated comments * Add additional missing case as well (#16) * Resolve review comments and added test cases for null, min, max and incorrect value format * Handle Exception * Handle INet * Handle Code Formate * Added format and removeed raw import * Added Null handling * Added test cases for all remaining of cassandra datatype * Address the formatter case * Updated Comment * mvn spotless:apply fixes * Type handler ut fixes (#17) * removed unwanted <> from comments * Added Fixes for String formate * Fix spotapply * Type handler ut fixes (#18) * removed unwanted <> from comments * Added Fixes for String formate * Fix spotapply * Fixed the review comments and add Test with a non-zero offset and happy test * Fixed the review comments and add Test with a non-zero offset and happy test * Handle Sppoty fixes --------- Co-authored-by: Narendra Rajput <narendra.rajput@ollion.com> * Handle Inet from GCP package and also added Long Cast for List of Long * Fix UT and Checklist style * Handle Timestamp to Instant * Fix UT and consolidate Instant Parsing * Handle Fix related 2 date conversion * improved date parsing * Fixed review comments and coverage (#23) * Fixed review comments and increased coverage * ut_coverage_fixes * Fixed UT for Inetaddress --------- Co-authored-by: taherkl <taher.lakdawala@ollion.com> Co-authored-by: pawankashyapollion <v-pawan.kumar@ollion.com> Co-authored-by: Narendra Rajput <narendra.rajput@ollion.com>
Add nullable option support into BeamToJson [DATABEAM-40]