-
Notifications
You must be signed in to change notification settings - Fork 21
Handle complex JDBC types during string conversion #1007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Handle complex JDBC types during string conversion #1007
Conversation
- extend `StringConverter` to stringify Databricks complex wrappers, JDBC arrays/structs, and generic collections while falling back to `toString` for unknown objects (src/main/java/com/databricks/jdbc/api/impl/converters/StringConverter.java:25) - relax `ComplexDataTypeParser` timestamp parsing to accept ISO strings with `T` separators and timezone offsets (src/main/java/com/databricks/jdbc/api/impl/ComplexDataTypeParser.java:196) - broaden regression coverage for the new string handling and offset timestamp parsing (src/test/java/com/databricks/jdbc/api/impl/converters/StringConverterTest.java:166, src/test/java/com/databricks/jdbc/api/impl/ComplexDataTypeParserTest.java:134)
…lidation - Extend StringConverter to stringify Databricks complex wrappers (DatabricksArray, DatabricksMap, DatabricksStruct), JDBC arrays/structs, and generic collections while falling back to toString() for unknown objects - Add VARIANT type validation to ensure only String objects are accepted, maintaining backward compatibility - Relax ComplexDataTypeParser timestamp parsing to accept ISO strings with 'T' separators and timezone offsets (e.g., "2025-03-18T12:08:31.552223-07:00") - Broaden test coverage for new string handling and offset timestamp parsing
@jayantsing-db, this PR fixed other major issues with complex datatype parsing. Can you please review? |
…lidation - Extend StringConverter to stringify Databricks complex wrappers (DatabricksArray, DatabricksMap, DatabricksStruct), JDBC arrays/structs, and generic collections while falling back to toString() for unknown objects - Add VARIANT type validation to ensure only String objects are accepted, maintaining backward compatibility - Relax ComplexDataTypeParser timestamp parsing to accept ISO strings with 'T' separators and timezone offsets (e.g., "2025-03-18T12:08:31.552223-07:00") - Broaden test coverage for new string handling and offset timestamp parsing Signed-off-by: josecsotomorales <[email protected]>
…ality - Test SQL Array handling with mock objects and null cases - Test generic Struct conversion with attribute arrays and null handling - Test generic Map and Collection string conversion with mixed types - Test Java array conversion for primitive and object arrays - Test string escaping functionality via reflection - Test nested data structure conversion (maps in collections, etc.) - Add SQLException error path testing for robustness These tests improve branch coverage to meet the 85% requirement while ensuring all new complex type conversion paths are properly tested. Signed-off-by: josecsotomorales <[email protected]>
…ytics/databricks-jdbc into fix-complex-type-conversion
Do you have any feedback on this PR? This currently affects users who encounter string parsing issues in fields with complex data types. It would be great if we could get it merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one minor comment, LGTM otherwise. Adding @shivam2680 to double check conversions
src/main/java/com/databricks/jdbc/api/impl/ComplexDataTypeParser.java
Outdated
Show resolved
Hide resolved
Address PR review feedback by simplifying timestamp parsing logic: - Try Timestamp.valueOf() on original text first - If that fails, try with T replaced by space - Only fall back to custom parser for complex formats - Extract custom parsing logic to separate method for clarity Also update NEXT_CHANGELOG.md to properly describe all changes in this PR. Signed-off-by: josecsotomorales <[email protected]>
3d252ec
to
7c7140c
Compare
src/main/java/com/databricks/jdbc/api/impl/ComplexDataTypeParser.java
Outdated
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/ComplexDataTypeParser.java
Outdated
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/ComplexDataTypeParser.java
Outdated
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/converters/StringConverter.java
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/converters/StringConverter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/converters/StringConverter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/converters/StringConverter.java
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/converters/StringConverter.java
Show resolved
Hide resolved
src/main/java/com/databricks/jdbc/api/impl/converters/StringConverter.java
Show resolved
Hide resolved
- Refactor ComplexDataTypeParser to reuse TimestampConverter logic, eliminating duplicate timestamp parsing code while maintaining backward compatibility for timezone offset handling - Remove unnecessary stripQuotes() call since JsonNode.asText() already strips JSON quotes - Remove redundant DatabricksStruct instanceof check in StringConverter - Add defensive null checks for map entries and collection parameters - Standardize comma handling pattern across all StringConverter methods - Use WildcardUtil.isNullOrEmpty() for consistency with codebase Signed-off-by: josecsotomorales <[email protected]>
Description
Testing
mvn -Dtest=StringConverterTest,ComplexDataTypeParserTest test
Additional Notes to the Reviewer