Skip to content

Fix DECIMAL scale parsing bug in Trino-to-Rel converter#582

Open
zheliu2 wants to merge 3 commits intomasterfrom
zheliu/fix-decimal-scale-parsing
Open

Fix DECIMAL scale parsing bug in Trino-to-Rel converter#582
zheliu2 wants to merge 3 commits intomasterfrom
zheliu/fix-decimal-scale-parsing

Conversation

@zheliu2
Copy link
Copy Markdown
Contributor

@zheliu2 zheliu2 commented Mar 8, 2026

Summary

  • Fixes trino parser decimal type get wrong scala #453: CAST(a AS DECIMAL(38,4)) was incorrectly parsed as DECIMAL(38,38)
  • Root cause: copy-paste bug on line 1254 of ParseTreeBuilder.java where getArguments().get(0) was used for the scale parameter instead of getArguments().get(1)
  • Added two test cases for DECIMAL with explicit scale and DECIMAL with precision only

Testing Done

  • Unit tests added in TrinoToRelConverterTest for DECIMAL(38,4) and DECIMAL(10)
  • Full ./gradlew clean build passes (547 tasks, all tests green)

zheliu2 and others added 3 commits March 8, 2026 17:53
…#453)

The scale parameter in DECIMAL(precision, scale) was incorrectly reading
from the first argument (index 0) instead of the second argument (index 1),
causing CAST(a AS DECIMAL(38,4)) to be parsed as DECIMAL(38,38).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update copyright years to 2021-2026
- Add test cases for DECIMAL(18,9), DECIMAL(1,0), DECIMAL(38,38)
- Apply spotless formatting
Product test case expected outputs had decimal(p, p) due to the
bug where scale was read from the same argument as precision.
Updated 11 expected files to use the correct decimal(p, s) values.
@zheliu2 zheliu2 marked this pull request as ready for review March 8, 2026 23:35
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.

trino parser decimal type get wrong scala

1 participant