[ https://issues.apache.org/jira/browse/CALCITE-5118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17529508#comment-17529508 ]
Julian Hyde commented on CALCITE-5118: -------------------------------------- I’m a bit skeptical about the rewriteCall mechanism. But I’ll accept it if it gives the same behavior as doing things the usual way. So can you add tests that functions like WEEK give appropriate errors from the usual validation process when called with the wrong number of arguments, argument of the wrong type, or arguments that contain invalid expressions. Add them to the regular unit test method for WEEK (and maybe a similar function too). > SqlDatePartFunction#rewriteCall should check operands length > ------------------------------------------------------------ > > Key: CALCITE-5118 > URL: https://issues.apache.org/jira/browse/CALCITE-5118 > Project: Calcite > Issue Type: Improvement > Components: core > Affects Versions: 1.30.0 > Reporter: Benchao Li > Assignee: Benchao Li > Priority: Major > Labels: pull-request-available > Fix For: 1.31.0 > > Time Spent: 1h > Remaining Estimate: 0h > > {{SqlDatePartFunction#rewriteCall}} does not check operands length for now, > and it will be rewrite to {{EXTRACT}} unconditionally before validation. > E.g. > {code:sql} > select week(); -- will throw ArrayIndexOutOfBoundsException > select week(date '2022-04-27', 1); -- will just ignore second param > {code} > However, these cases should throw validation exceptions, because {{week}} > actually only accept 1 operand. -- This message was sent by Atlassian Jira (v8.20.7#820007)