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


##########
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:
   > "Invalid number of arguments to function 'WEEK'. Was expecting 1 arguments
   
   The fail message duplicates a lot. Can we use a variable instead?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to