Skip to content

Fixed getColumns function to return correct output for complex datatypes#974

Merged
msrathore-db merged 7 commits into
databricks:mainfrom
msrathore-db:PECOBLR-838
Sep 9, 2025
Merged

Fixed getColumns function to return correct output for complex datatypes#974
msrathore-db merged 7 commits into
databricks:mainfrom
msrathore-db:PECOBLR-838

Conversation

@msrathore-db
Copy link
Copy Markdown
Collaborator

@msrathore-db msrathore-db commented Aug 30, 2025

Description

Fixed getColumns function: SQL_DATATYPE, SQL_DATETIME_SUB, DATA_TYPE, TYPE_NAME,BUFFER_LENGTH. Used StripBaseTypeName instead of StripTypeName to fix the incorrect values in case of complex datatypes.

Testing

Tested manually

RELATED TICKETS AND DOCUMENTS

PECOBLR-838

Fixes #955

… TYPE_NAME,BUFFER_LENGTH. Used StripBaseTypeName instead of StripTypeName to fix the incorrect values in case of complex datatypes
.columnType(columnType)
.columnTypeText(
metadataResultSetBuilder.stripTypeName(
metadataResultSetBuilder.stripBaseTypeName(
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.

what is changing stripTypeName to stripBaseTypeName fixing exactly?

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.

we don't need to change for thrift resultsetmetadata?

Copy link
Copy Markdown
Collaborator Author

@msrathore-db msrathore-db Sep 1, 2025

Choose a reason for hiding this comment

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

So now instead of returning array<INT> it'll simply return the base type that is array.
For thrift, it uses another method but the behaviour is same for that as well.

…ComplexDatatypeSuppor is 0. Added tests for the same
if (typeVal != null
&& (typeVal.contains(DATE_TYPE) || typeVal.contains(TIMESTAMP_TYPE))) {
object = getCode(stripTypeName(typeVal));
&& (stripBaseTypeName(typeVal).contains(DATE_TYPE)
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.

nice!

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.

Thanks!

* @param typeVal The type string to check
* @return true if the type is a complex type, false otherwise
*/
private boolean isComplexType(String typeVal) {
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.

what abt variant?

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.

Since variant is not a complex type so we do not need to handle it differently

@msrathore-db msrathore-db merged commit 4fdf34f into databricks:main Sep 9, 2025
12 of 13 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.

[BUG] DatabaseMetadata.getColumns returning enum of zero for data type instead of 12 varchar

3 participants