[
https://issues.apache.org/jira/browse/CALCITE-5024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17498193#comment-17498193
]
Julian Hyde commented on CALCITE-5024:
--------------------------------------
For literals, I think we should not use the default precision; we should use a
precision sufficient for the literal (but not less than the default precision).
So there would be no need to use a special type system.
Reviewing the PR, I see a lot of redundant code; let's eliminate that
redundancy. Also, I wouldn't add a case in SqlToRelConverterTest; instead add
to misc.iq (alongside tests for CALCITE-922); maybe also a test in
SqlValidatorTest.testIntervalMillisConversion.
> Big INTERVAL_HOUR precision can't be converted to row expression
> ----------------------------------------------------------------
>
> Key: CALCITE-5024
> URL: https://issues.apache.org/jira/browse/CALCITE-5024
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.29.0
> Environment: jdk8
> Reporter: yanjing.wang
> Assignee: yanjing.wang
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> {code:java}
> @Test void testBigIntervalHourPrecision() {
> String expr = "interval '1000000' hour";
> expr(expr).withFactory(t -> t.withTypeFactoryFactory(
> f -> new JavaTypeFactoryImpl() {
> @Override
> public RelDataTypeSystem getTypeSystem() {
> return new RelDataTypeSystemImpl() {
> @Override
> public int getDefaultPrecision(SqlTypeName typeName) {
> switch (typeName) {
> case INTERVAL_HOUR:
> return SqlTypeName.MAX_INTERVAL_START_PRECISION;
> default:
> break;
> }
> return super.getDefaultPrecision(typeName);
> }
> };
> }
> }
> )).ok();
> } {code}
> This will cause SqlValidatorException: Interval field value 1,000,000 exceeds
> precision of HOUR(2) field.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)