[CALCITE-6654] NUMERIC/DECIMAL columns without explicit precision should not throw \"DECIMAL precision 0 must be between 1 and 19#4872
Conversation
…thout explicit precision
| } | ||
| } | ||
|
|
||
| private static boolean isAffectedTypeForMissingPrecision(SqlTypeName sqlTypeName) { |
There was a problem hiding this comment.
This function looks like overkill.
Do you expect it will need to cover other cases too?
I would just inline the function.
There was a problem hiding this comment.
the condition is now just sqlTypeName == SqlTypeName.DECIMAL directly at the call site.
| } else if (precision >= 0 && sqlTypeName.allowsPrecNoScale()) { | ||
|
|
||
| // Fix for CALCITE-6654: | ||
| // Oracle returns scale=-127 for NUMBER without precision |
There was a problem hiding this comment.
The comment about oracle is informative, but it's not clear how it relates to the code here.
| */ | ||
| @Tag("integration") | ||
| @EnabledIfSystemProperty(named = "calcite.integration.tests", matches = "true") | ||
| public class JdbcSchemaDecimalBugTest { |
There was a problem hiding this comment.
I don't understand where the DECIMAL without precision is.
Where is this table test_numbers?
There was a problem hiding this comment.
I've updated the tests to create the table within each test method using CREATE TABLE ... (val NUMERIC) / (val DECIMAL) / (val NUMBER) without explicit precision, which is exactly the scenario that triggers CALCITE-6654. The table is dropped and recreated at the start of each test run.
…ion in JdbcSchema
|
|
I see this is a draft, please request a new review when this is ready |



Jira Link
CALCITE-6654
Changes Proposed
JdbcSchema.sqlType()threw anIllegalArgumentExceptionwhen a columnwas declared without explicit precision. Oracle reports
precision=0andscale=-127for such columns (e.g.NUMBER), PostgreSQL and MSSQL reportprecision=0andscale=0(e.g.NUMERIC,DECIMAL).Treat
precision=0(and Oracle'sscale=-127) as "no precisionspecified" and fall back to the plain SQL type instead of throwing.
Testing
Added
JdbcSchemaDecimalBugTestwith 4 integration tests covering Oracle,PostgreSQL, MSSQL, and a regression test for explicit
DECIMAL(10,2).