Skip to content

Add nullable option support into fromJson [DATABEAM-39]#23

Merged
ilya-kozyrev merged 3 commits intoProtegrityIntegrationTemplatefrom
databeam_39
May 12, 2021
Merged

Add nullable option support into fromJson [DATABEAM-39]#23
ilya-kozyrev merged 3 commits intoProtegrityIntegrationTemplatefrom
databeam_39

Conversation

@RaphaelSanamyan
Copy link
Copy Markdown

Add nullable option support into BeamToJson [DATABEAM-40]

@RaphaelSanamyan RaphaelSanamyan changed the base branch from master to ProtegrityIntegrationTemplate May 11, 2021 14:56
}


private static boolean getOptionalBoolean(JsonNode node, String key, boolean defaultValue) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this method is for reading a boolean field in JSON, which might not exist

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any other cases where we need to read boolean values from json?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this moment there are no other cases.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it, I think this way the code looks a bit more clear

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());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be not repeatable, because order of fields not guarantee after deserialization

}


private static boolean getOptionalBoolean(JsonNode node, String key, boolean defaultValue) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it, I think this way the code looks a bit more clear

@ilya-kozyrev ilya-kozyrev merged commit f81413c into ProtegrityIntegrationTemplate May 12, 2021
Amar3tto pushed a commit that referenced this pull request Mar 27, 2025
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants