[
https://issues.apache.org/jira/browse/FLINK-31090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17689444#comment-17689444
]
luoyuxia commented on FLINK-31090:
----------------------------------
[~Sergey Nuyanzin] Thanks. Yes, the quoted 'select interval '2' day is fine.
The reason is they share different plan, for 'SELECT INTERVAL 2 DAY':
{code:java}
LogicalSink(table=[*anonymous_collect$1*], fields=[EXPR$0])
LogicalProject(EXPR$0=[*(1, 86400000:INTERVAL DAY)])
LogicalValues(tuples=[[{ 0 }]]) {code}
for 'select interval '2' day, the plan is like:
{code:java}
LogicalSink(table=[*anonymous_collect$1*], fields=[EXPR$0])
LogicalProject(EXPR$0=[86400000:INTERVAL DAY])
LogicalValues(tuples=[[{ 0 }]]) {code}
.
The exception happens in code gen stage for the expression ' *(1,
86400000:INTERVAL DAY)'. It requires the left operand is interval type. But i
think it should be fine/reasonable that the right operand is interval type and
the left is a numeric type.
Although quoting is fine, I still think we also should support it with no
quoting for it looks like just a bug.
> Flink SQL fail to select INTERVAL
> ----------------------------------
>
> Key: FLINK-31090
> URL: https://issues.apache.org/jira/browse/FLINK-31090
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner, Table SQL / Runtime
> Reporter: luoyuxia
> Priority: Major
>
> Can be reproduce in CalcITCase with the following code:
>
> {code:java}
> @Test def testSelectInterval(): Unit = { checkResult("SELECT INTERVAL 2 DAY",
> data3) }
> {code}
>
>
> It'll throw the exception:
> org.apache.flink.table.planner.codegen.CodeGenException: Interval expression
> type expected.
> at
> org.apache.flink.table.planner.codegen.CodeGenUtils$.requireTimeInterval(CodeGenUtils.scala:419)
> at
> org.apache.flink.table.planner.codegen.ExprCodeGenerator.generateCallExpression(ExprCodeGenerator.scala:549)
> at
> org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:490)
> at
> org.apache.flink.table.planner.codegen.ExprCodeGenerator.visitCall(ExprCodeGenerator.scala:57)
> at org.apache.calcite.rex.RexCall.accept(RexCall.java:189)
> at
> org.apache.flink.table.planner.codegen.ExprCodeGenerator.generateExpression(ExprCodeGenerator.scala:143)
> at
> org.apache.flink.table.planner.codegen.ExpressionReducer.$anonfun$reduce$2(ExpressionReducer.scala:81)
> at scala.collection.immutable.List.map(List.scala:282)
> at
> org.apache.flink.table.planner.codegen.ExpressionReducer.reduce(ExpressionReducer.scala:81)
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)