wnob commented on code in PR #2980:
URL: https://github.com/apache/calcite/pull/2980#discussion_r1029900371


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -206,6 +206,14 @@ private SqlLibraryOperators() {
               .andThen(SqlTypeTransforms.TO_VARYING), null,
           OperandTypes.STRING, SqlFunctionCategory.STRING);
 
+  /** BigQuery's "SUBSTR(value1, value2)" function. */

Review Comment:
   typo?



##########
babel/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -178,6 +199,7 @@ SqlCreate SqlCreateTable(Span s, boolean replace) :
 |   < DATEPART: "DATEPART" >
 |   < NEGATE: "!" >
 |   < TILDE: "~" >
+|   < STARTS_WITH: "STARTS_WITH" >

Review Comment:
   nit: I believe this should be alphabetically sorted



##########
babel/src/test/resources/sql/big-query.iq:
##########
@@ -2519,4 +2519,31 @@ SELECT PARSE_TIMESTAMP("%c", "Thu Dec 25 07:30:00 2008") 
AS parsed;
 !ok
 !}
 
+#####################################################################
+#
+# STARTS_WITH(value1, value2)
+#
+# Takes two STRING or BYTES values. Returns TRUE if the second value is a 
prefix of the first.
+#
+# This function supports specifying collation.
+WITH items AS
+  (SELECT 'foo' as item

Review Comment:
   These are all strings, but your function accepts 
`OperandTypes.STRING_STRING` which includes bytes objects as well. We should 
test those too (I think you need another overload in `SqlFunctions`).
   
   I also think you may need to specify that both arguments must have the same 
type, and I'm not sure if `OperandTypes.STRING_STRING` accomplishes that. There 
should be a test to make sure you can't call `STARTS_WITH` passing a string and 
a bytes together. Double check that this is consistent with BigQuery by running 
a sample query in the BQ console, since their documentation isn't 100% clear.



-- 
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