julianhyde commented on a change in pull request #1380: [CALCITE-3252] Syntax 
error while parsing CONVERT_TIMEZONE, TO_DATE, TO_TIMESTAMP functions on 
Redshift
URL: https://github.com/apache/calcite/pull/1380#discussion_r314472192
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java
 ##########
 @@ -171,6 +171,44 @@ private SqlLibraryOperators() {
           ReturnTypes.VARCHAR_2000, null, OperandTypes.DATETIME,
           SqlFunctionCategory.TIMEDATE);
 
+  /** The "TO_DATE(string1, string2)" function; casts string1
+   * to a date using the format specified in string2 */
+  @LibraryOperator(libraries = {POSTGRESQL, ORACLE})
+  public static final SqlFunction TO_DATE =
+      new SqlFunction(
+          "TO_DATE",
+          SqlKind.OTHER_FUNCTION,
+          ReturnTypes.DATE_NULLABLE,
+          null,
+          OperandTypes.STRING_STRING,
+          SqlFunctionCategory.TIMEDATE);
+
+  /** The "TO_TIMESTAMP(string1, string2)" function; casts string1
+   * to a timestamp using the format specified in string2 */
+  @LibraryOperator(libraries = {POSTGRESQL, ORACLE})
+  public static final SqlFunction TO_TIMESTAMP =
+      new SqlFunction(
+          "TO_TIMESTAMP",
+          SqlKind.OTHER_FUNCTION,
+          ReturnTypes.DATE_NULLABLE,
+          null,
+          OperandTypes.STRING_STRING,
+          SqlFunctionCategory.TIMEDATE);
+
+  /** The "CONVERT_TIMEZONE(string1, string2, datetime)" function;
+   * converts the timezone of the datetime from string1 to string2.
+   * This function is only on Redshift, but we list it in Postgresql
+   * because Redshift does not have its own library. */
 
 Review comment:
   SqlLibrary is an enum, so it's not easy to make fine-grained changes. If we 
added a REDSHIFT library it would be mostly the same as POSTGRESQL, but we 
would then have to register every function in both libraries. It seems simpler 
to have one extra function in the POSTGRESQL (which is inaccurate but not very 
harmful) than to create a new REDSHIFT library.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to