macroguo-ghy commented on code in PR #3417:
URL: https://github.com/apache/calcite/pull/3417#discussion_r1334039745
##########
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:
Good suggestion! I add this `SqlTypeTransforms` as you recommended. But a
litter different from #3430, because in #3430, `TO_ARRAY_NULLABLE` is defined
as
`ARG0`
`.andThen(SqlTypeTransforms.TO_ARRAY)`
`.andThen(SqlTypeTransforms.TO_NULLABLE)`,
which can not be used in my PR.
##########
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:
Maybe related to encoding. I copy the "spaces" to Sublime Text, the spaces
converted to `<0x03><0x03>`
--
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]