Skip to content

Add support for DECIMAL(M, D) columns in MySQL EET - #1352

Merged
mrigger merged 1 commit into
mainfrom
feature/eet-decimal-support
Aug 3, 2026
Merged

Add support for DECIMAL(M, D) columns in MySQL EET#1352
mrigger merged 1 commit into
mainfrom
feature/eet-decimal-support

Conversation

@tlmorgan24

Copy link
Copy Markdown
Collaborator

Summary

The EET oracle's type inference previously required FLOAT/DOUBLE/DECIMAL columns to be created without an (M, D) precision/scale specifier, because its type-pinning CAST (used for the redundant branch of transformation rules No. 3–4) could only target the bare types.

This PR removes the exclusion for DECIMAL by tracking a column's exact (M, D) end-to-end and reproducing it as CAST(... AS DECIMAL(M, D)). FLOAT/DOUBLE remain excluded under EET. This is because FLOAT(M, D)/DOUBLE(M, D) is not a valid CAST target, so there is no way to reproduce such a column's exact type in a type-pinning cast (also note FLOAT(M, D)/DOUBLE(M, D) columns are deprecated anyway, but they still remain supported for all other oracles).

Changes

Schema — track scale (MySQLSchema.java)

  • Added a scale field (+ getScale()) to MySQLColumn, read from information_schema.columns.NUMERIC_SCALE, alongside the already-read NUMERIC_PRECISION.
  • The MySQLColumn constructor and its single call site now thread scale through. information_schema always reports a concrete (M, D) for a DECIMAL column, defaulting to (10, 0) when the column was declared without one.

Type domain — enrich CastType (MySQLCastOperation.java)

  • MySQLCastOperation.CastType was changed from a plain enum into a small final value class. Its keyword kinds (SIGNED, UNSIGNED, CHAR, FLOAT, DOUBLE, DECIMAL) remain public static final singletons (so existing e.g. == CastType.SIGNED comparisons are unaffected), while CastType.decimal(m, d) produces DECIMAL instances carrying (M, D).
  • Added getPrecision/getScale, equals/hashCode (over kind + (M, D)), and a toString that renders DECIMAL(M, D).

Transformer (MySQLEETTransformer.java)

  • inferColumnType maps a DECIMAL column to CastType.decimal(column.getPrecision(), column.getScale()).
  • commonType compares with .equals() instead of ==, so two DECIMAL subexpressions with matching (M, D) (distinct instances) share a type. If (M, D) differs, commonType conservatively returns null, as MySQL's precise aggregation rule in this case is not known.

Table generation (MySQLTableGenerator.java)

  • DECIMAL has now been reverted to the original behaviour of calling optionallyAddPrecisionAndScale (i.e. (M, D) is now allowed under EET).
  • FLOAT/DOUBLE route through a new optionallyAddFloatingPointPrecisionAndScale, which omits (M, D) only while EET is active.

@tlmorgan24
tlmorgan24 requested a review from mrigger July 31, 2026 05:39

@mrigger mrigger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@mrigger
mrigger merged commit 0f54adf into main Aug 3, 2026
24 of 25 checks passed
@mrigger
mrigger deleted the feature/eet-decimal-support branch August 3, 2026 13:44
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.

2 participants