[PECOBLR-414]Prepared Statement getMetaData to work without executing Query#838
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enables PreparedStatement.getMetaData to retrieve metadata from a DESCRIBE QUERY command without executing the actual query. Key changes include:
- Adding new helper methods and tests to extract and strip base type names.
- Updating metadata retrieval across DatabricksStatement, DatabricksResultSetMetaData, and DatabricksPreparedStatement.
- Adjusting logging and access modifiers to support the new DESCRIBE QUERY flow.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/databricks/jdbc/dbclient/impl/common/MetadataResultSetBuilderTest.java | Added tests for the new stripBaseTypeName method. |
| src/test/java/com/databricks/jdbc/api/impl/DatabricksResultSetMetaDataTest.java | Introduced tests for metadata initialization using DESCRIBE QUERY. |
| src/main/java/com/databricks/jdbc/dbclient/impl/common/MetadataResultSetBuilder.java | Added the stripBaseTypeName helper function for type-name extraction. |
| src/main/java/com/databricks/jdbc/api/impl/DatabricksStatement.java | Modified metadata fetching logic and updated the connection field access modifier. |
| src/main/java/com/databricks/jdbc/api/impl/DatabricksResultSetMetaData.java | Added a new constructor and precision/scale parsing logic for DESCRIBE QUERY. |
| src/main/java/com/databricks/jdbc/api/impl/DatabricksPreparedStatement.java | Updated getMetaData to retrieve metadata via DESCRIBE QUERY and added helper methods. |
| } | ||
| // Checking '<' first and then '(' to handle cases like MAP<STRING,INT>(50) | ||
|
|
||
| // Checks for ARRAY<STRING> -> ARRAY |
There was a problem hiding this comment.
this is done only for this use case? Not needed for other cases?
There was a problem hiding this comment.
What do you mean by other cases ?
There was a problem hiding this comment.
I meant for regular resultSetMetadata, why is this being added now? I was more thinking if we are adding duplicate code
There was a problem hiding this comment.
We can't reuse the same code, because current code is written for SEA which returns ARRAY<INT> and Thrift returns ARRAY. Our implementation aligns with the thrift flow
Description
This PR introduces functions that allow
PreparedStatement.getMetaData()to return metadata information without requiring the query to be executed first.Functioning
We call the
DESCRIBE QUERYcommand to fetch the metadata, this returns thecolumn_namesandcolumn_typesand obviously additional info such as total rows will not be availableTesting