Skip to content

[cdc] Fix PostgresTypeUtils to map out-of-range numeric precision to STRING#8610

Open
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/cdc-postgres-numeric-precision
Open

[cdc] Fix PostgresTypeUtils to map out-of-range numeric precision to STRING#8610
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/cdc-postgres-numeric-precision

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Purpose

fix #8605

  • Postgres numeric allows precision up to 1000, but Paimon DecimalType.MAX_PRECISION is 38, so PostgresTypeUtils.toDataType() threw IllegalArgumentException on a numeric(50,2) column and schema derivation failed before the CDC sink could start.
  • Now precision > 38 falls back to STRING (ARRAY(STRING) for _numeric); precision 0 default (DECIMAL(38,18)) and the 1..38 behavior are preserved.
  • Mirrors the sibling MySqlTypeUtils.toDataType() guard (length <= 38 ? DECIMAL : STRING) under the same JdbcToPaimonTypeVisitor SPI.

Tests

  • Added PostgresTypeUtilsTest covering precision 50 → STRING, 10/38 → DECIMAL, 0 → DECIMAL(38,18), and _numeric array symmetry.
  • mvn -pl paimon-flink/paimon-flink-cdc -am -Pflink1 clean install — 4 tests passed (checkstyle/spotless/rat green).

…STRING

Postgres numeric allows precision up to 1000, but Paimon DecimalType.MAX_PRECISION
is 38, so numeric(50,2) made schema derivation throw IllegalArgumentException.
Fall back to STRING (ARRAY(STRING) for _numeric) when precision exceeds 38,
mirroring the sibling MySqlTypeUtils guard. Precision 0 default and the 1..38
behavior are preserved.

Generated-by: Claude Code
@JingsongLi

Copy link
Copy Markdown
Contributor

Currently, only precision > 38 is checked; numeric(10,20) and negative scale values still result in the DECIMAL constructor being called and an IllegalArgumentException being thrown. Local minimum validation: 50,2 -> STRING; 10,20 and 10,-2 both result in exceptions. It is recommended to also validate scale < 0 || scale > precision.

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.

[Bug] PostgresTypeUtils crashes on numeric precision > 38 instead of falling back to STRING

2 participants