tanclary commented on code in PR #3417:
URL: https://github.com/apache/calcite/pull/3417#discussion_r1333242359
##########
babel/src/test/resources/sql/big-query.iq:
##########
@@ -2029,6 +2029,160 @@ SELECT CODE_POINTS_TO_BYTES(array[2147483648, 1]);
Input arguments of CODE_POINTS_TO_BYTES out of range: 2147483648
!error
+#####################################################################
+# CODE_POINTS_TO_STRING(array<integer>)
+#
+# Takes an array of Unicode code points as ARRAY<INT64>
+# and returns a STRING.
+#
+SELECT CODE_POINTS_TO_STRING(array[65, 66, 67, 68]) as result;
++--------+
+| result |
++--------+
+| ABCD |
++--------+
+(1 row)
+
+!ok
+
+SELECT CODE_POINTS_TO_STRING(array[255, 254, 1024, 70000]) as result;
++--------+
+| result |
++--------+
+| ÿþЀ𑅰 |
++--------+
+(1 row)
+
+!ok
+
+SELECT CODE_POINTS_TO_STRING(array[1+2, 3]) as result;
++--------+
+| result |
++--------+
+| |
Review Comment:
Why does the spacing look off here, do you know?
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1793,6 +1793,22 @@ private static RelDataType
deriveTypeMapFromEntries(SqlOperatorBinding opBinding
OperandTypes.ARRAY_OF_INTEGER,
SqlFunctionCategory.STRING);
+ @LibraryOperator(libraries = {BIG_QUERY})
+ public static final SqlFunction CODE_POINTS_TO_STRING =
+ SqlBasicFunction.create("CODE_POINTS_TO_STRING",
+ ReturnTypes.VARCHAR_NULLABLE,
+ OperandTypes.ARRAY_OF_INTEGER,
+ SqlFunctionCategory.STRING);
+
+ @LibraryOperator(libraries = {BIG_QUERY})
+ public static final SqlFunction TO_CODE_POINTS =
+ SqlBasicFunction.create("TO_CODE_POINTS",
+ ReturnTypes.INTEGER
Review Comment:
Ah okay that is what I figured. Thanks for explaining.
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1793,6 +1793,22 @@ private static RelDataType
deriveTypeMapFromEntries(SqlOperatorBinding opBinding
OperandTypes.ARRAY_OF_INTEGER,
SqlFunctionCategory.STRING);
+ @LibraryOperator(libraries = {BIG_QUERY})
+ public static final SqlFunction CODE_POINTS_TO_STRING =
+ SqlBasicFunction.create("CODE_POINTS_TO_STRING",
+ ReturnTypes.VARCHAR_NULLABLE,
+ OperandTypes.ARRAY_OF_INTEGER,
+ SqlFunctionCategory.STRING);
+
+ @LibraryOperator(libraries = {BIG_QUERY})
+ public static final SqlFunction TO_CODE_POINTS =
+ SqlBasicFunction.create("TO_CODE_POINTS",
+ ReturnTypes.INTEGER
Review Comment:
As a follow up, would the `TO_ARRAY_NULLABLE` that could be added
here:https://github.com/apache/calcite/pull/3430 be helpful in this case?
--
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]