[
https://issues.apache.org/jira/browse/CALCITE-7443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18066671#comment-18066671
]
Zhen Chen commented on CALCITE-7443:
------------------------------------
I verified this in PostgreSQL, and it also reports an error indicating that the
value exceeds the integer range.
Perhaps we could perform a check within
`StandardConvertletTable#convertInterval` and then throw an error.
{code:java}
private static RexNode convertInterval(SqlRexContext cx, SqlCall call) {
// "INTERVAL n HOUR" becomes "n * INTERVAL '1' HOUR"
final SqlNode n = call.operand(0);
final SqlIntervalQualifier intervalQualifier = call.operand(1);
/** Check YEAR Integer overflow */
final SqlIntervalLiteral literal =
SqlLiteral.createInterval(1, "1", intervalQualifier,
call.getParserPosition());
final SqlCall multiply =
SqlStdOperatorTable.MULTIPLY.createCall(call.getParserPosition(), n,
literal);
return cx.convertExpression(multiply);
} {code}
> Incorrect simplification for large interval
> -------------------------------------------
>
> Key: CALCITE-7443
> URL: https://issues.apache.org/jira/browse/CALCITE-7443
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.41.0
> Reporter: Mihai Budiu
> Priority: Minor
>
> The following passes as a quidem test:
> {code:java}
> SELECT INTERVAL 2147483647 years;
> +--------+
> | EXPR$0 |
> +--------+
> | -1 |
> +--------+
> (1 row)
> !ok{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)