xuzifu666 commented on code in PR #4703:
URL: https://github.com/apache/calcite/pull/4703#discussion_r2638857815
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -2774,4 +2774,33 @@ private static RelDataType
deriveTypeMapFromEntries(SqlOperatorBinding opBinding
public static final SqlFunction RANDOM = SqlStdOperatorTable.RAND
.withName("RANDOM")
.withOperandTypeChecker(OperandTypes.NILADIC);
+
+
+ /**
+ * AGE function for PostgreSQL.
+ * Returns the interval between two timestamps in DAY TO SECOND format.
+ *
+ * @see <a
href="https://www.postgresql.org/docs/current/functions-datetime.html">PostgreSQL
AGE</a>
+ */
+ @LibraryOperator(libraries = {POSTGRESQL}, exceptLibraries = {REDSHIFT})
Review Comment:
What are the reasons for excluding ```REDSHIFT``` here?
##########
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]
+ * AGE function with timestamp arguments</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')",
Review Comment:
Is the result returned here exactly the same as that of PG?
##########
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]
+ * AGE function with timestamp arguments</a>. */
Review Comment:
also here.
##########
babel/src/test/java/org/apache/calcite/test/BabelTest.java:
##########
@@ -490,4 +496,45 @@ private void checkSqlResult(String funLibrary, String
query, String result) {
.query(query)
.returns(result);
}
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7337">[CALCITE-7337]
+ * AGE function with timestamp arguments</a>. */
Review Comment:
This is inconsistent with the information in the issue.
--
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]