Skip to content

[CALCITE-7563] Oracle dialect generates invalid CAST to VARCHAR without precision#4973

Open
zzwqqq wants to merge 1 commit into
apache:mainfrom
zzwqqq:fix_oracle_unparse_varchar
Open

[CALCITE-7563] Oracle dialect generates invalid CAST to VARCHAR without precision#4973
zzwqqq wants to merge 1 commit into
apache:mainfrom
zzwqqq:fix_oracle_unparse_varchar

Conversation

@zzwqqq
Copy link
Copy Markdown
Contributor

@zzwqqq zzwqqq commented May 28, 2026

Jira Link

CALCITE-7563

Changes Proposed

Oracle treats VARCHAR as synonymous with VARCHAR2, and VARCHAR2 requires a size. RelToSqlConverter with OracleSqlDialect could generate invalid SQL such as CAST(expr AS VARCHAR) when the target VARCHAR type had unspecified precision.

Use the Oracle type system's max precision for VARCHAR in this case, and add a regression test.

@sonarqubecloud
Copy link
Copy Markdown

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-7563">[CALCITE-7563]
* Oracle dialect generates invalid CAST to VARCHAR without precision</a>. */
@Test void testCastVarcharWithoutPrecisionOracle() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume you have already tested these sql in Oracle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. I have tested the SQL against a real Oracle instance and here https://onecompiler.com/oracle/44qmsuytf

@xuzifu666
Copy link
Copy Markdown
Member

After version 1.42 is released, I will merge this pr if there are no other comments.

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