Skip to content

Decouple decimal conversion from arrow metadata#856

Merged
vikrantpuppala merged 6 commits into
databricks:mainfrom
vikrantpuppala:decimal-arrow-decouple
Jun 24, 2025
Merged

Decouple decimal conversion from arrow metadata#856
vikrantpuppala merged 6 commits into
databricks:mainfrom
vikrantpuppala:decimal-arrow-decouple

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

Description

Decouple decimal conversion from arrow metadata

Testing

Unit tests

Additional Notes to the Reviewer

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 decouples decimal conversion from Arrow metadata by using ColumnInfo objects instead of parsing strings, and updates all related utility methods and tests to pass ColumnInfo.

  • Introduces getColumnInfoFromTColumnDesc to build ColumnInfo with type qualifiers
  • Replaces string‐only metadata parsing with ColumnInfo in ArrowToJavaObjectConverter and downstream call sites
  • Updates tests to supply ColumnInfo instances where appropriate

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/com/databricks/jdbc/common/util/DatabricksThriftUtil.java Added getColumnInfoFromTColumnDesc and mapping from Thrift types to ColumnInfoTypeName
src/main/java/com/databricks/jdbc/api/impl/converters/ArrowToJavaObjectConverter.java Changed convert* methods to accept ColumnInfo for decimal and other conversions
src/main/java/com/databricks/jdbc/api/impl/DatabricksResultSetMetaData.java Switched from Thrift descriptors to ColumnInfo, removed old type‐desc helpers
src/test/java/.../util/DatabricksThriftUtilTest.java Updated tests to use getColumnInfoFromTColumnDesc
src/test/java/.../converters/ArrowToJavaObjectConverterTest.java Updated converter tests to pass ColumnInfo
src/test/java/.../arrow/InlineChunkProviderTest.java Updated chunk provider tests to use ColumnInfo
src/test/java/.../arrow/ArrowResultChunkTest.java Updated result‐chunk tests to pass ColumnInfo
src/test/java/.../DatabricksResultSetMetaDataTest.java Refactored metadata tests to use ColumnInfo
src/main/java/com/databricks/jdbc/common/util/DatabricksTypeUtil.java Renamed Thrift‐type helper to return TPrimitiveTypeEntry
Other Arrow‐ and stream‐related classes Updated various call sites to thread ColumnInfo through conversions
NEXT_CHANGELOG.md Added entry about decimal conversion fix
Comments suppressed due to low confidence (4)

src/main/java/com/databricks/jdbc/common/util/DatabricksThriftUtil.java:180

  • Consider setting columnInfo.setTypeText(getTypeTextFromTypeDesc(columnDesc.getTypeDesc())) so the returned ColumnInfo includes both the logical type name and its text representation, fully capturing the original metadata.
  public static ColumnInfo getColumnInfoFromTColumnDesc(TColumnDesc columnDesc) {

src/main/java/com/databricks/jdbc/common/util/DatabricksTypeUtil.java:447

  • [nitpick] The method name getTPrimitiveTypeOrDefault is a bit unclear; renaming it to something like getPrimitiveEntryFromTypeDesc would improve readability and express intent more directly.
  public static TPrimitiveTypeEntry getTPrimitiveTypeOrDefault(TTypeDesc typeDesc) {

src/main/java/com/databricks/jdbc/api/impl/converters/ArrowToJavaObjectConverter.java:267

  • Add unit tests for convertToDecimal covering cases where columnInfo.getTypeScale() is null to verify that no scaling is applied by default.
  static BigDecimal convertToDecimal(Object object, ColumnInfo columnInfo)

src/main/java/com/databricks/jdbc/api/impl/DatabricksResultSetMetaData.java:7

  • [nitpick] Wildcard static imports can obscure which methods are used. Consider importing only the specific static methods you need for better clarity.
import static com.databricks.jdbc.common.util.DatabricksThriftUtil.*;

if (object instanceof Number) {
return new BigDecimal(object.toString()).setScale(scale, RoundingMode.HALF_UP);
if (object instanceof Text || object instanceof Number) {
BigDecimal bigDecimal = new BigDecimal(object.toString());

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 had a comment on this on original PR. Instead of doing toString, for many of number types, we can parse the value from respective number types

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.

I'm not very inclined to introduce this change in this PR, since it works, i don't want to unintentionally break something

@github-actions

Copy link
Copy Markdown

📊 Code Coverage Report

Overall Project 86.16% -0.09% 🟢
Files changed 88.22% 🟢

File Coverage
DatabricksResultSetMetaData.java 93.25% 🟢
DatabricksTypeUtil.java 91.49% 🟢
DatabricksThriftUtil.java 88.75% -5.28% 🟢
InlineChunkProvider.java 87.16% 🟢
ArrowResultChunk.java 86.59% 🟢
ArrowStreamResult.java 81.5% -0.63% 🟢
ArrowToJavaObjectConverter.java 78.41% 🟢

@vikrantpuppala vikrantpuppala merged commit e86213c into databricks:main Jun 24, 2025
15 of 17 checks passed
@vikrantpuppala vikrantpuppala deleted the decimal-arrow-decouple branch June 24, 2025 10:53
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