Skip to content

[PECOBLR-414]Prepared Statement getMetaData to work without executing Query#838

Merged
jprakash-db merged 11 commits into
mainfrom
jprakash-db/pstmt-get-metadata
May 30, 2025
Merged

[PECOBLR-414]Prepared Statement getMetaData to work without executing Query#838
jprakash-db merged 11 commits into
mainfrom
jprakash-db/pstmt-get-metadata

Conversation

@jprakash-db

@jprakash-db jprakash-db commented May 27, 2025

Copy link
Copy Markdown
Collaborator

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 QUERY command to fetch the metadata, this returns the column_names and column_types and obviously additional info such as total rows will not be available

Testing

  • Added unit tests
  • Added fake service tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksStatement.java
Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksPreparedStatement.java Outdated
@jprakash-db jprakash-db changed the title Prepared Statement getMetaData to work without executing Query [PECOBLR-414]Prepared Statement getMetaData to work without executing Query May 27, 2025
@jprakash-db jprakash-db marked this pull request as ready for review May 28, 2025 04:40
}
// Checking '<' first and then '(' to handle cases like MAP<STRING,INT>(50)

// Checks for ARRAY<STRING> -> ARRAY

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is done only for this use case? Not needed for other cases?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean by other cases ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I meant for regular resultSetMetadata, why is this being added now? I was more thinking if we are adding duplicate code

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksPreparedStatement.java Outdated
Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksPreparedStatement.java Outdated
Comment thread src/main/java/com/databricks/jdbc/api/impl/DatabricksPreparedStatement.java Outdated
@jprakash-db jprakash-db merged commit 8693d24 into databricks:main May 30, 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.

4 participants