mihaibudiu commented on code in PR #3784:
URL: https://github.com/apache/calcite/pull/3784#discussion_r1591683789


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -270,6 +270,13 @@ private static SqlCall transformConvert(SqlValidator 
validator, SqlCall call) {
               .andThen(SqlTypeTransforms.TO_NULLABLE_ALL),
           OperandTypes.SAME_SAME);
 
+  /** The "NVL(value, value)" function. */
+  @LibraryOperator(libraries = {SPARK})
+  public static final SqlBasicFunction ADD_MONTHS =

Review Comment:
   According to the Databricks documentation ADD_MONTHS takes an expression 
that evaluates to a date, and not a string: 
https://docs.databricks.com/en/sql/language-manual/functions/add_months.html
   
   The result is also supposed to be a DATE.
   
   I have already asked this question in a prior review. Reviews take a lot of 
energy and time, so please listen to the comments if you expect people to 
review your PRs.



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10418,6 +10418,23 @@ void checkNvl(SqlOperatorFixture f0, FunctionAlias 
functionAlias) {
     f0.forEachLibrary(list(functionAlias.libraries), consumer);
   }
 
+  @Test void testAddMonthsFunc() {
+    final SqlOperatorFixture f0 = fixture();
+    f0.setFor(SqlLibraryOperators.ADD_MONTHS);
+    f0.checkFails("^add_months('2016-08-31', 1)^",
+        "No match found for function signature "
+            + "ADD_MONTHS\\(<CHARACTER>, <NUMERIC>\\)", false);
+
+    final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK);
+    f.checkScalar("ADD_MONTHS('2016-08-31', 1)", "2016-09-30",

Review Comment:
   you should test with invalid dates too, and with dates prior to the 
Gregorian calendar introduction.
   You should also test with negative values for the number of months.



-- 
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