Skip to content

fix(transform): correct decimal and binary truncate literals - #3243

Open
advancedxy wants to merge 1 commit into
apache:mainfrom
advancedxy:codex/fix-truncate-literal
Open

advancedxy wants to merge 1 commit into
apache:mainfrom
advancedxy:codex/fix-truncate-literal

Conversation

@advancedxy

Copy link
Copy Markdown

This problem is identified during the internal implementation and review of #2456, which we noticed the problem when added truncated related filters and rejects binary input.

Which issue does this PR close?

No issue is currently linked.

What changes are included in this PR?

The Arrow array path already preserves decimal precision and scale and supports binary truncation. The literal path instead reset decimal scale to zero and rejected binary values. For example, truncate50 returned 1050 instead of 10.50.

Align literal truncation with the Arrow array path: preserve the source decimal precision and scale, and return the first W bytes of binary values, or the entire value when shorter. Decimal projection boundary adjustments must also preserve precision and scale to keep their values correct before truncation.

Are these changes tested?

Updated test.

AI Disclosure

OpenAI Codex was used for implementation. I reviewed the changes against repository conventions.

The Arrow array path already preserves decimal precision and scale and
supports binary truncation. The literal path instead reset decimal scale
to zero and rejected binary values. For example, truncate[50](10.65)
returned 1050 instead of 10.50.

Align literal truncation with the Arrow array path: preserve the source
decimal precision and scale, and return the first W bytes of binary
values, or the entire value when shorter. Decimal projection boundary
adjustments must also preserve precision and scale to keep their values
correct before truncation.
@advancedxy

Copy link
Copy Markdown
Author

@CTTY @mbutrovich would you mind to take a look at this. I think this is a correctness fix.

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.

1 participant