Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-3468] JDBC adapter may generate casts on Oracle for varchar without the precision and for char with the precision exceeding max length of Oracle #1861

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wenhuitang
Copy link
Contributor

Oracle requires VARCHAR with precision, and the max precision of VARCHAR is 4000, the max precision of CHAR is 2000. When the precision of CHAR is not assigned, it has the default value 1 which is the same as Calcite.

@wenhuitang wenhuitang closed this Mar 20, 2020
@wenhuitang wenhuitang reopened this Mar 20, 2020
if (type.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
type = allowTypeWithUnspecifiedPrecision(type)
? type
: new SqlTypeFactoryImpl(getTypeSystem()).createSqlType(type.getSqlTypeName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of create a new type, i would prefer to let the SqlTypeUtil.convertTypeToSpec(type, charSet, maxPrecision) support a explicit precision parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot , I have already addressed.

* @return corresponding parse representation
*/
public static SqlDataTypeSpec convertTypeToSpec(RelDataType type,
String charSetName, int maxPrecision) {
String charSetName, int maxPrecision,
boolean allowsPrecisionUnspecified, int defaultPrecision) {
SqlTypeName typeName = type.getSqlTypeName();
Copy link
Contributor

@danny0405 danny0405 Mar 26, 2020

Choose a reason for hiding this comment

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

I would suggest to replace allowsPrecisionUnspecified and defaultPrecision with a single explicitPrecision, and if a explicitPrecision is specified, use it directly. Leave out the complex allowsPrecisionUnspecified decision to the invoker.

Copy link
Contributor Author

@wenhuitang wenhuitang Mar 26, 2020

Choose a reason for hiding this comment

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

This pull request has been updated, thanks for your reviewing, it's really helpful.

…without the precision and for char with the precision exceeding max length of Oracle (Wenhui Tang)
@DonnyZone
Copy link
Contributor

Hi @wenhuitang, could you rebase the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted-and-would-rework-soon This patch is overall ok, but need some refactoring by the committers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants