Skip to content

Add Short and BigDecimal type mappings to SqlTypeUtils#763

Open
gknz wants to merge 2 commits into
apache:mainfrom
gknz:feature/sqltypeutils-short-bigdecimal-mapping
Open

Add Short and BigDecimal type mappings to SqlTypeUtils#763
gknz wants to merge 2 commits into
apache:mainfrom
gknz:feature/sqltypeutils-short-bigdecimal-mapping

Conversation

@gknz
Copy link
Copy Markdown

@gknz gknz commented May 30, 2026

Summary

Adds proper SQL type handling for Short and java.math.BigDecimal across the
table-sink write path. Previously these had no entry in the JDBC type map, so the
sink created such columns as VARCHAR(255) in overwrite mode and bound the values
as strings.

Changes

  • SqlTypeUtils: map Short/shortSMALLINT and BigDecimalNUMERIC
    (the PostgreSQL dialect inherits both from the default map).
  • JavaTableSink: bind values via setShort / setBigDecimal instead of the
    setString fallback.
  • SparkTableSink: map ShortShortType and BigDecimal
    DecimalType(38, 18) (Spark's default precision/scale) so the DataFrame writes
    SMALLINT / NUMERIC columns instead of text.

Testing

Verified end-to-end against PostgreSQL on both the Java and Spark platforms: a
record of (Integer, Short, BigDecimal) now produces integer / smallint /
numeric columns with the exact values on both write paths.

gepa and others added 2 commits May 30, 2026 16:39
Short and java.math.BigDecimal had no entry in the JDBC type map, so columns of those Java types were created as VARCHAR(255) by the JDBC table sink in overwrite mode. Map Short (and short) to SMALLINT and BigDecimal to NUMERIC; the PostgreSQL dialect map inherits both from the default map.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
SqlTypeUtils now maps Short->SMALLINT and BigDecimal->NUMERIC for the generated
DDL, but the sinks still bound those values via the String fallback. Complete the
write path:
- JavaTableSink: bind via setShort / setBigDecimal
- SparkTableSink: map Short->ShortType and BigDecimal->DecimalType(38,18) so the
  Spark DataFrame writes SMALLINT / NUMERIC columns instead of text
@mspruc
Copy link
Copy Markdown
Contributor

mspruc commented Jun 1, 2026

Hi thanks for the contribution, if possible it would also be nice to have a unit test for this

@zkaoudi
Copy link
Copy Markdown
Contributor

zkaoudi commented Jun 1, 2026

@mspruc what unit test do you have in mind? This PR seems to simply add two more data types

@mspruc
Copy link
Copy Markdown
Contributor

mspruc commented Jun 1, 2026

@zkaoudi well something that tests the sinks ideally, e.g. for https://github.com/gknz/wayang/blob/efb35979111a6bb84192acd2ade8424bcd1ee463/wayang-platforms/wayang-spark/src/main/java/org/apache/wayang/spark/operators/SparkTableSink.java#L156

we have two magic numbers, I'd like to make sure this conversion is stable.

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.

3 participants