mihaibudiu commented on code in PR #3915: URL: https://github.com/apache/calcite/pull/3915#discussion_r1718953093
########## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ########## @@ -13824,6 +13824,54 @@ void testTimestampDiff(boolean coercionEnabled) { f.checkNull("date_add(CAST(NULL AS DATE), interval 5 day)"); } + /** Test case for + * <a href="https://issues.apache.org/jira/browse/CALCITE-6527">[CALCITE-6527] + * Add DATE_ADD function (enabled in Spark library)</a>. + */ + @Test void testDateAddSpark() { + final SqlOperatorFixture f0 = fixture() + .setFor(SqlLibraryOperators.DATE_ADD_SPARK); + f0.checkFails("^date_add(date '2008-12-25', " + + "5)^", + "No match found for function signature " + + "DATE_ADD\\(<DATE>, <NUMERIC>\\)", false); + + final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK); + f.checkScalar("date_add(date '2016-02-22', 2)", + "2016-02-24", + "DATE NOT NULL"); + f.checkScalar("date_add(date '2016-02-28', 2)", + "2016-03-01", + "DATE NOT NULL"); + f.checkScalar("date_add(date '2016-03-01', -2)", + "2016-02-28", + "DATE NOT NULL"); + f.checkScalar("date_add(date '2016-03-01', -2)", + "2016-02-28", + "DATE NOT NULL"); + f.checkScalar("date_add(date '2016-03-01', -2.0)", + "2016-02-28", + "DATE NOT NULL"); + f.checkScalar("date_add(date '2016-02-28', 2.0)", + "2016-03-01", + "DATE NOT NULL"); + f.checkScalar("date_add(date '2016-02-28', '2.0')", + "2016-03-01", + "DATE NOT NULL"); + f.checkScalar("date_add(timestamp '2016-02-22 13:00:01', '-2.0')", + "2016-02-20", + "DATE NOT NULL"); + f.checkScalar("date_add(timestamp '2016-02-22 13:00:01', -2)", + "2016-02-20", + "DATE NOT NULL"); + f.checkScalar("date_add(timestamp '2016-02-22 13:00:01', -2.0)", + "2016-02-20", + "DATE NOT NULL"); + f.checkNull("date_add(CAST(NULL AS DATE), 5)"); + f.checkNull("date_add(date '2016-02-22', CAST(NULL AS INTEGER))"); Review Comment: I think that in my previous review I asked for a few more tests around boundary conditions, I don't see any here. -- 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-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org