normanj-bitquill commented on code in PR #3792:
URL: https://github.com/apache/calcite/pull/3792#discussion_r1613655476


##########
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:
   No. The implementations of `hashCode` and `equals` are from `SqlOperator` 
and only looks at the name and kind.
   
   There is also a `TO_CHAR` for MySQL/Oracle and this new one for PostgreSQL. 
Since they have the same name and kind they would conflict in a HashMap. Using 
a new class here gets around the collision. Another solution is to add `equals` 
and `hashCode` implementations to `SqlBasicFunction`.



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to