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


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10862,6 +10810,47 @@ private static void 
checkArrayConcatAggFuncFails(SqlOperatorFixture t) {
         "3", "BIGINT NOT NULL");
   }
 
+  @Test void testExtractTime() {
+    final SqlOperatorFixture f = fixture();
+    f.setFor(SqlStdOperatorTable.EXTRACT, VM_FENNEL, VM_JAVA);
+
+    final String fail = "Cannot apply 'EXTRACT' to arguments of type 
'EXTRACT\\(<.*> "
+        + "FROM <TIME\\(0\\)>\\)'\\. "
+        + "Supported form\\(s\\): .*\\n.*\\n.*";
+
+    f.checkFails("extract(^a^ from time '12:34:56')",
+        "'A' is not a valid time frame", false);
+    f.checkFails("^extract(epoch from time '12:34:56')^",
+        fail, false);
+
+    f.checkScalar("extract(second from time '12:34:56')",
+        "56", "BIGINT NOT NULL");
+    f.checkScalar("extract(millisecond from time '12:34:56')",
+        "56000", "BIGINT NOT NULL");
+    f.checkScalar("extract(microsecond from time '12:34:56')",
+        "56000000", "BIGINT NOT NULL");
+    f.checkScalar("extract(nanosecond from time '12:34:56')",
+        "56000000000", "BIGINT NOT NULL");
+    f.checkScalar("extract(minute from time '12:34:56')",
+        "34", "BIGINT NOT NULL");
+    f.checkScalar("extract(hour from time '12:34:56')",
+        "12", "BIGINT NOT NULL");
+    f.checkFails("^extract(day from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(month from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(quarter from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(year from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(isoyear from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(doy from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(dow from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(week from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(decade from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(century from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(century from time '12:34:56')^", fail, false);
+    f.checkFails("^extract(century from time '12:34:56')^", fail, false);

Review Comment:
   noticed some duplicated tests, I will delete these before merging.



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