Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-39484: [Java] Support 256 bit decimals in JdbcToArrowUtils #39485

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

aiguofer
Copy link
Contributor

@aiguofer aiguofer commented Jan 6, 2024

Rationale for this change

This PR allows users of JdbcToArrowUtils to convert 256 bit decimals.

What changes are included in this PR?

Add a Decimal256Consumer and logic to

Are these changes tested?

No, at this point there are no good tests for JDBC consumers.

Are there any user-facing changes?

Converting 256 bit decimals and ints bigger than 64 bit should now work

@aiguofer aiguofer requested a review from lidavidm as a code owner January 6, 2024 00:03
Copy link

github-actions bot commented Jan 6, 2024

⚠️ GitHub issue #39484 has been automatically assigned in GitHub to PR creator.

@@ -169,7 +171,11 @@ public static ArrowType getArrowTypeFromJdbcType(final JdbcFieldInfo fieldInfo,
case Types.DECIMAL:
int precision = fieldInfo.getPrecision();
int scale = fieldInfo.getScale();
return new ArrowType.Decimal(precision, scale, 128);
if (precision > 38) {
Copy link
Contributor Author

@aiguofer aiguofer Jan 6, 2024

Choose a reason for hiding this comment

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

Is this correct? this is how BigQuery seems to handle it, but not sure if it's any different on the Arrow side.

Copy link
Member

Choose a reason for hiding this comment

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

Should be right. Arrow Decimal128 maxes out at 38 as well.

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jan 6, 2024
Comment on lines 171 to 172
if (precision > 18) {
return new ArrowType.Decimal(precision, 0);
Copy link
Contributor Author

@aiguofer aiguofer Jan 6, 2024

Choose a reason for hiding this comment

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

We ran into an issue with this on Snowflake, which can have precision up to 38 (128 bit). Although technically some 19 precision numbers can be expressed in 64 bit, the safest way to ensure the conversion always works seems to be setting it to Decimal if the column precision > 18.

I can remove this, or add it in a separate PR if ya'll think think that's better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nvm... I removed this since it broke some tests.

@aiguofer aiguofer force-pushed the support_256_decimal branch from 162a45f to 2b7624d Compare January 6, 2024 00:45
@@ -169,7 +171,11 @@ public static ArrowType getArrowTypeFromJdbcType(final JdbcFieldInfo fieldInfo,
case Types.DECIMAL:
int precision = fieldInfo.getPrecision();
int scale = fieldInfo.getScale();
return new ArrowType.Decimal(precision, scale, 128);
if (precision > 38) {
Copy link
Member

Choose a reason for hiding this comment

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

Should be right. Arrow Decimal128 maxes out at 38 as well.

@lidavidm lidavidm merged commit 1622a2e into apache:main Jan 8, 2024
31 of 32 checks passed
@lidavidm lidavidm removed the awaiting committer review Awaiting committer review label Jan 8, 2024
@github-actions github-actions bot added the awaiting merge Awaiting merge label Jan 8, 2024
Copy link

After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 1622a2e.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them.

clayburn pushed a commit to clayburn/arrow that referenced this pull request Jan 23, 2024
…pache#39485)

### Rationale for this change

This PR allows users of `JdbcToArrowUtils` to convert 256 bit decimals.

### What changes are included in this PR?

Add a `Decimal256Consumer` and logic to 

### Are these changes tested?

No, at this point there are no good tests for JDBC consumers.

### Are there any user-facing changes?

Converting 256 bit decimals and ints bigger than 64 bit should now work

* Closes: apache#39484

Authored-by: Diego Fernandez <aiguo.fernandez@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
…pache#39485)

### Rationale for this change

This PR allows users of `JdbcToArrowUtils` to convert 256 bit decimals.

### What changes are included in this PR?

Add a `Decimal256Consumer` and logic to 

### Are these changes tested?

No, at this point there are no good tests for JDBC consumers.

### Are there any user-facing changes?

Converting 256 bit decimals and ints bigger than 64 bit should now work

* Closes: apache#39484

Authored-by: Diego Fernandez <aiguo.fernandez@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Feb 28, 2024
…pache#39485)

### Rationale for this change

This PR allows users of `JdbcToArrowUtils` to convert 256 bit decimals.

### What changes are included in this PR?

Add a `Decimal256Consumer` and logic to 

### Are these changes tested?

No, at this point there are no good tests for JDBC consumers.

### Are there any user-facing changes?

Converting 256 bit decimals and ints bigger than 64 bit should now work

* Closes: apache#39484

Authored-by: Diego Fernandez <aiguo.fernandez@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Java] Support 256 bit Decimals in JdbcToArrowUtils
2 participants