[CALCITE-6654] NUMERIC/DECIMAL columns without explicit precision should not throw \"DECIMAL precision 0 must be between 1 and 19#4872
Conversation
| } | ||
| } | ||
|
|
||
| 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.
|
I see this is a draft, please request a new review when this is ready |
|
Is this ready for review? |
|
|
| * Run with: | ||
| ** {@code ./gradlew :core:integTestCalcite6654} | ||
| * | ||
| * <p>Required Docker containers (see docker-compose in src/test/resources): |
There was a problem hiding this comment.
I could not find a file named docker-compose in this repository.
What does this refer to?
There was a problem hiding this comment.
I've added the docker-compose.yml to core/src/test/resources/ and updated the Javadoc reference accordingly. @mihaibudiu
…thout explicit precision [CALCITE-6654] Handle NUMERIC/DECIMAL columns without explicit precision in JdbcSchema [CALCITE-6654] Fix JdbcSchema error for DECIMAL/NUMERIC columns without explicit precision
731edd5 to
e381117
Compare
…cite-6654-decimal-precision
|
you should use new commits for changes until they are approved, and squash at that point |
|
|
you can check the changes using |
thomaskirz
left a comment
There was a problem hiding this comment.
Fix linter-reported formatting issues. This should resolve the CI error.
| /** | ||
| * PostgreSQL {@code NUMERIC} without precision (e.g. {@code col NUMERIC}) | ||
| * must not cause Calcite to throw. | ||
| * <p>PostgreSQL reports {@code precision=0, scale=0} for such columns. |
There was a problem hiding this comment.
| * <p>PostgreSQL reports {@code precision=0, scale=0} for such columns. | |
| * | |
| * <p>PostgreSQL reports {@code precision=0, scale=0} for such columns. |
| ResultSet rs = | ||
| st.executeQuery("SELECT * FROM \"oracle\".\"TEST_NUMBERS\"")) { | ||
| while (rs.next()) { | ||
| //drain |
|
Fixed the two checkstyle issues, CI should pass now. |
|
thanks. seems like there are still some issues, i'll have a look at it |
|
looks like a test assertion is failing |
87fd4a0 to
ae9d27b
Compare
|
|
Thanks for the review, @thomaskirz and @mihaibudiu! I see that PR #4941 was merged to main with a similar fix, so I'm closing this PR as superseded. I also verified that #4941 covers the Oracle case (precision=0, scale=-127) via the fallthrough path. |



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).