YiwenWu commented on code in PR #3792:
URL: https://github.com/apache/calcite/pull/3792#discussion_r1610856426
##########
babel/src/test/resources/sql/postgresql.iq:
##########
@@ -58,11 +58,356 @@ NAME, PAY_BY_QUARTER, SCHEDULE
Bill, [10000, 10000, 10000, 10000], [[meeting, lunch], [training,
presentation]]
!ok
-select to_char(timestamp '2022-06-03 12:15:48.678', 'YYYY-MM-DD HH24:MI:SS.MS
TZ');
+select to_char(timestamp '2022-06-03 12:15:48.678', 'YYYY-MM-DD
HH24:MI:SS.MS');
EXPR$0
2022-06-03 12:15:48.678
!ok
+select to_char(timestamp '2022-06-03 12:15:48.678', 'HH');
+EXPR$0
+12
+!ok
+
+select to_char(timestamp '2022-06-03 13:15:48.678', 'HH12');
+EXPR$0
+01
+!ok
+
+select to_char(timestamp '2022-06-03 13:15:48.678', 'HH24');
+EXPR$0
+13
+!ok
+
+select to_char(timestamp '2022-06-03 13:15:48.678', 'MI');
Review Comment:
rich unit tests 👍
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1651,13 +1652,22 @@ private static RelDataType
deriveTypeMapFromEntries(SqlOperatorBinding opBinding
*
* <p>({@code TO_CHAR} is not supported in MySQL, but it is supported in
* MariaDB, a variant of MySQL covered by {@link SqlLibrary#MYSQL}.) */
- @LibraryOperator(libraries = {MYSQL, ORACLE, POSTGRESQL})
+ @LibraryOperator(libraries = {MYSQL, ORACLE})
public static final SqlFunction TO_CHAR =
SqlBasicFunction.create("TO_CHAR",
- ReturnTypes.VARCHAR,
+ ReturnTypes.VARCHAR_NULLABLE,
OperandTypes.TIMESTAMP_STRING,
SqlFunctionCategory.TIMEDATE);
+ /** The "TO_CHAR(timestamp, format)" function;
+ * converts {@code timestamp} to string according to the given {@code
format}. */
+ @LibraryOperator(libraries = {POSTGRESQL})
+ public static final SqlFunction TO_CHAR_PG =
+ new SqlBasicFunction("TO_CHAR", SqlKind.OTHER_FUNCTION,
Review Comment:
Can this be used directly?
```
SqlBasicFunction.create("TO_CHAR",
ReturnTypes.VARCHAR_NULLABLE,
OperandTypes.TIMESTAMP_STRING,
SqlFunctionCategory.TIMEDATE);
```
--
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]