[FLINK-39418] Fix decimal truncation when precision / scale is over 19#4375
Open
yuxiqian wants to merge 2 commits intoapache:masterfrom
Open
[FLINK-39418] Fix decimal truncation when precision / scale is over 19#4375yuxiqian wants to merge 2 commits intoapache:masterfrom
yuxiqian wants to merge 2 commits intoapache:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes FLINK-39418 by ensuring Flink CDC’s Calcite-based transform parsing/type inference supports DECIMAL precision/scale beyond 19 (up to 38), preventing truncation in YAML pipeline transforms.
Changes:
- Introduce a custom Calcite
RelDataTypeSystem(FlinkCdcTypeSystem) with DECIMAL precision/scale limits aligned to Flink CDC’sDecimalType(38). - Wire the custom type system into
TransformParserand its unit tests. - Update/extend transform spec and IT assertions to cover higher-precision DECIMAL behavior (including
DECIMAL(38, *)).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/TransformParser.java |
Uses the custom type system when creating Calcite SqlTypeFactoryImpl. |
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/FlinkCdcTypeSystem.java |
New type system raising max numeric precision/scale to 38. |
flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/parser/TransformParserTest.java |
Updates tests to use the custom type system. |
flink-cdc-composer/src/test/resources/specs/decimal.yaml |
Updates golden outputs for DECIMAL arithmetic results/types. |
flink-cdc-composer/src/test/resources/specs/casting.yaml |
Updates/extends casting golden outputs, adding DECIMAL(38, *) cases. |
flink-cdc-composer/src/test/java/org/apache/flink/cdc/composer/flink/FlinkPipelineTransformITCase.java |
Adds IT assertions covering maximum DECIMAL precision castings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/converter/CommonConverter.java
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This closes FLINK-39418.
Currently, Flink CDC uses Apache Calcite's default
RelDataTypeSystemImplwhich only supports decimal up to 19 precision and scale, but YAML pipeline may handle decimal types up to 38. Unexpected data truncation may occur.