You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/05/23 13:27:51 UTC

[GitHub] [calcite] chunweilei commented on a diff in pull request #2782: [CALCITE-5118] SqlDatePartFunction#rewriteCall should check operands length

chunweilei commented on code in PR #2782:
URL: https://github.com/apache/calcite/pull/2782#discussion_r879456733


##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -8977,6 +8977,43 @@ public void _testGroupExpressionEquivalenceParams() {
         .rewritesTo(expected2);
   }
 
+  @Test void testDatePartWithRewrite() {
+    final String sql = "select week(date '2022-04-27'), year(date '2022-04-27')";
+    final String expected = "SELECT EXTRACT(WEEK FROM DATE '2022-04-27'),"
+        + " EXTRACT(YEAR FROM DATE '2022-04-27')";
+    sql(sql)
+        .withValidatorCallRewrite(true)
+        .rewritesTo(expected);
+
+    final String noParamSql = "select ^week()^";
+    sql(noParamSql)
+        .withValidatorCallRewrite(true)
+        .fails("Invalid number of arguments to function 'WEEK'. Was expecting 1 arguments");
+
+    final String multiParamsSql = "select ^week(date '2022-04-27', 1)^";
+    sql(multiParamsSql)
+        .withValidatorCallRewrite(true)
+        .fails("Invalid number of arguments to function 'WEEK'. Was expecting 1 arguments");
+  }
+
+  @Test void testDatePartWithoutRewrite() {

Review Comment:
   I do not stick to it. Let us leave it as-is.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org