Skip to content

[FLINK-39418] Fix decimal truncation when precision / scale is over 19#4375

Open
yuxiqian wants to merge 2 commits intoapache:masterfrom
yuxiqian:FLINK-39418
Open

[FLINK-39418] Fix decimal truncation when precision / scale is over 19#4375
yuxiqian wants to merge 2 commits intoapache:masterfrom
yuxiqian:FLINK-39418

Conversation

@yuxiqian
Copy link
Copy Markdown
Member

This closes FLINK-39418.

Currently, Flink CDC uses Apache Calcite's default RelDataTypeSystemImpl which only supports decimal up to 19 precision and scale, but YAML pipeline may handle decimal types up to 38. Unexpected data truncation may occur.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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’s DecimalType (38).
  • Wire the custom type system into TransformParser and 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@yuxiqian yuxiqian marked this pull request as ready for review April 10, 2026 13:27
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.

2 participants