-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
base: main
Are you sure you want to change the base?
Conversation
if (type.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) { | ||
type = allowTypeWithUnspecifiedPrecision(type) | ||
? type | ||
: new SqlTypeFactoryImpl(getTypeSystem()).createSqlType(type.getSqlTypeName()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
56514ed
to
04f89cc
Compare
04f89cc
to
e85cc72
Compare
* @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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
e85cc72
to
2a9a71c
Compare
Hi @wenhuitang, could you rebase the PR? |
8a5cf83
to
cf7f71b
Compare
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.