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.
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
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.
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)
Type domain — enrich CastType (MySQLCastOperation.java)
Transformer (MySQLEETTransformer.java)
Table generation (MySQLTableGenerator.java)