cjj2010 commented on code in PR #4703:
URL: https://github.com/apache/calcite/pull/4703#discussion_r2646463889
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -6948,6 +6948,105 @@ void checkRegexpExtract(SqlOperatorFixture f0,
FunctionAlias functionAlias) {
f.checkNull("json_storage_size(cast(null as varchar))");
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7337">[CALCITE-7337]
+ * There is no age function that supports pgSQL</a>. */
+ @Test void testAgePg() {
Review Comment:
> Need to add invalid date format test?
done, thanks
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -6948,6 +6948,105 @@ void checkRegexpExtract(SqlOperatorFixture f0,
FunctionAlias functionAlias) {
f.checkNull("json_storage_size(cast(null as varchar))");
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7337">[CALCITE-7337]
+ * There is no age function that supports pgSQL</a>. */
+ @Test void testAgePg() {
+ final SqlOperatorFixture f0 = fixture();
+ f0.checkFails("^age(timestamp '2023-12-25', timestamp '2020-01-01')^",
+ "No match found for function signature AGE\\(<TIMESTAMP>,
<TIMESTAMP>\\)", false);
+
+ final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.POSTGRESQL);
+
+ // Test two timestamp arguments
+ f.checkScalar("age(timestamp '2023-12-25', timestamp '2020-01-01')",
+ "3 years 11 mons 24 days 0 hours 0 mins 0.0 secs",
+ "VARCHAR NOT NULL");
+
+ f.checkScalar("age(timestamp '2023-01-01', timestamp '2023-01-01')",
+ "0 years 0 mons 0 days 0 hours 0 mins 0.0 secs",
+ "VARCHAR NOT NULL");
+
+ f.checkScalar("age(timestamp '2020-01-01', timestamp '2023-12-25')",
+ "-3 years -11 mons -24 days 0 hours 0 mins 0.0 secs",
+ "VARCHAR NOT NULL");
+
+ f.checkScalar("age(timestamp '2023-02-01', timestamp '2023-01-31')",
+ "0 years 0 mons 1 days 0 hours 0 mins 0.0 secs",
+ "VARCHAR NOT NULL");
+
+ f.checkScalar("age(timestamp '2023-12-26 14:30:00', timestamp '2023-12-25
14:30:00')",
+ "0 years 0 mons 1 days 0 hours 0 mins 0.0 secs",
+ "VARCHAR NOT NULL");
+
+ f.checkScalar("age(timestamp '2023-12-25 00:00:00', timestamp '2020-01-01
23:59:59')",
+ "3 years 11 mons 23 days 0 hours 0 mins 1.0 secs",
+ "VARCHAR NOT NULL");
+
+ // Test single timestamp argument (relative to current time)
+ f.checkType("age(timestamp '2023-12-25')", "VARCHAR NOT NULL");
+
+
Review Comment:
> Extra blank lines
done
--
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]