Skip to content

Adds fallback for complex types [ES-1469237]#834

Merged
madhav-db merged 8 commits into
mainfrom
es-1469237
May 27, 2025
Merged

Adds fallback for complex types [ES-1469237]#834
madhav-db merged 8 commits into
mainfrom
es-1469237

Conversation

@madhav-db

@madhav-db madhav-db commented May 20, 2025

Copy link
Copy Markdown
Collaborator

Description

Added a static isComplexType utility method to DatabricksResultSet and ArrowStreamResult to consistently identify complex data types (ARRAY, MAP, STRUCT)
Updated the getObject method to use this utility method for identifying complex types and treat them as strings when complex datatype support is disabled.

This change fixes a NullPointerException that occurred when handling complex data types (ARRAY, MAP, STRUCT) with complex datatype support disabled. The issue appeared in workflows where:

  1. Users queried tables containing complex data types (arrays, maps, structs)
  2. Complex datatype support was disabled in their connection (EnableComplexDataTypes=0)
  3. The application attempted to retrieve the data via getObject() method
    The NPE occurred because the code was trying to call toString() on a null object when handling complex types with support disabled.

Testing

Added comprehensive unit tests to verify error handling when complex datatypes are accessed without enabling support
We conducted memory testing comparing our implementation with both the original code and the Databricks JDBC driver v2.7.3:
Test results showed comparable memory usage across both drivers
Using large arrays (100KB+) and multiple rows (50+) did not reveal memory inefficiencies

Additional Notes to the Reviewer

NO_CHANGELOG=true (This is a bug fix that addresses an internal error without changing the external API.)

@madhav-db madhav-db changed the title Adds fallback for complex types Adds fallback for complex types [ES-ES-1469237] May 27, 2025
…n messages for disabled support

- Introduced a private method `isComplexType` to streamline complex type checks.
- Updated exception messages in `getArray`, `getMap`, and `getStruct` methods to provide clearer guidance on enabling complex datatype support.
- Added unit tests to verify exception handling when complex datatype support is disabled.
@madhav-db madhav-db changed the title Adds fallback for complex types [ES-ES-1469237] Adds fallback for complex types [ES-1469237] May 27, 2025
@madhav-db madhav-db requested a review from gopalldb May 27, 2025 05:40
Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksResultSet.java Outdated
Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksResultSet.java Outdated
Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksResultSet.java Outdated
Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksResultSet.java Outdated
…QLException

- Updated methods getArray, getStruct, and getMap to throw DatabricksSQLException with specific error codes when complex datatype support is disabled.
- Enhanced logging for error conditions to improve debugging and user guidance.
- Adjusted unit tests to verify the new exception types and error codes.
@madhav-db madhav-db requested a review from gopalldb May 27, 2025 06:05
…en complex datatype support is disabled.

- Improved clarity in handling complex types by logging the conversion to STRING when necessary.
@madhav-db madhav-db merged commit 58b850e into databricks:main May 27, 2025
16 checks passed
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.

2 participants