You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "dssysolyatin (via GitHub)" <gi...@apache.org> on 2023/03/31 08:34:32 UTC
[GitHub] [calcite] dssysolyatin commented on a diff in pull request #3134: [CALCITE-5619] Add support for TO_CHAR
dssysolyatin commented on code in PR #3134:
URL: https://github.com/apache/calcite/pull/3134#discussion_r1154189969
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -863,6 +863,16 @@ static RelDataType deriveTypeSplit(SqlOperatorBinding operatorBinding,
OperandTypes.STRING.or(OperandTypes.BINARY),
SqlFunctionCategory.STRING);
+ /** The "TO_CHAR(timestamp, format)" function;
+ * converts {@code timestamp} to string according to the given {@code format}.
+ */
+ @LibraryOperator(libraries = {MYSQL, ORACLE, POSTGRESQL})
+ public static final SqlFunction TO_CHAR =
Review Comment:
PostgreSQL has 3 different to_char:
`to_char ( timestamp, text ) → text`
`to_char ( interval, text ) → text`
`to_char ( numeric_type, text ) → text`
You implemented only it for timestamp type. Can you specify it in jira ticket
##########
babel/src/test/resources/sql/postgresql.iq:
##########
@@ -57,3 +57,8 @@ SELECT * FROM sal_emp;
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');
Review Comment:
Can you add more tests for `toChar(DataContext ctx, long timestamp, String pattern)` function in org.apache.calcite.test.SqlFunctionsTest ?
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java:
##########
@@ -583,6 +584,7 @@ Builder populate2() {
defineMethod(TIME, "time", NullPolicy.STRICT);
// Datetime formatting methods
+ map.put(TO_CHAR, new ToCharImplementor());
Review Comment:
Use `defineMethod` instead of `ToChatImplementor`
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org