You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "macroguo-ghy (via GitHub)" <gi...@apache.org> on 2023/09/10 17:17:43 UTC
[GitHub] [calcite] macroguo-ghy opened a new pull request, #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
macroguo-ghy opened a new pull request, #3417:
URL: https://github.com/apache/calcite/pull/3417
…abled in BigQuery 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.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] macroguo-ghy commented on pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1735451352
Hi @tanclary, could you please review this PR again if you have time?
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] macroguo-ghy commented on a diff in pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on code in PR #3417:
URL: https://github.com/apache/calcite/pull/3417#discussion_r1330318436
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1130,14 +1130,70 @@ public static String charFromUtf8(int n) {
assert codePoint instanceof Number;
long cp = ((Number) codePoint).longValue();
if (cp < 0 || cp > 255) {
- throw RESOURCE.inputArgumentsOfCodePointsToBytesOutOfRange(cp).ex();
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange(
+ "CODE_POINTS_TO_BYTES", cp, "[0, 255]").ex();
}
bytes[i] = (byte) cp;
}
return new ByteString(bytes);
}
+ /**
+ * SQL CODE_POINTS_TO_STRING function.
Review Comment:
Fixed.
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] tanclary commented on a diff in pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on code in PR #3417:
URL: https://github.com/apache/calcite/pull/3417#discussion_r1328876095
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1130,14 +1130,70 @@ public static String charFromUtf8(int n) {
assert codePoint instanceof Number;
long cp = ((Number) codePoint).longValue();
if (cp < 0 || cp > 255) {
- throw RESOURCE.inputArgumentsOfCodePointsToBytesOutOfRange(cp).ex();
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange(
+ "CODE_POINTS_TO_BYTES", cp, "[0, 255]").ex();
}
bytes[i] = (byte) cp;
}
return new ByteString(bytes);
}
+ /**
+ * SQL CODE_POINTS_TO_STRING function.
Review Comment:
nit: `CODE_POINTS_TO_STRING(list)` (to match other functions)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] macroguo-ghy commented on a diff in pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on code in PR #3417:
URL: https://github.com/apache/calcite/pull/3417#discussion_r1328039931
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1130,14 +1130,68 @@ public static String charFromUtf8(int n) {
assert codePoint instanceof Number;
long cp = ((Number) codePoint).longValue();
if (cp < 0 || cp > 255) {
- throw RESOURCE.inputArgumentsOfCodePointsToBytesOutOfRange(cp).ex();
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange("CODE_POINTS_TO_BYTES", cp).ex();
}
bytes[i] = (byte) cp;
}
return new ByteString(bytes);
}
+ /**
+ * SQL CODE_POINTS_TO_STRING function.
+ */
+ public static @Nullable String codePointsToString(List codePoints) {
+ StringBuilder sb = new StringBuilder();
+ for (Object codePoint: codePoints) {
+ if (codePoint == null) {
+ return null;
+ }
+ assert codePoint instanceof Number;
+ long cp = ((Number) codePoint).longValue();
+ // Each valid code point should fall within the range of [0, 0xD7FF] and [0xE000, 0x10FFFF]
+ if (cp >= 0 && cp <= 0xD7FF || cp >= 0xE000 && cp <= 0x10FFFF) {
+ sb.append(charFromUtf8((int) cp));
+ } else {
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange("CODE_POINTS_TO_STRING", cp).ex();
+ }
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * SQL TO_CODE_POINTS(string) function.
+ */
+ public static @Nullable List<Integer> toCodePoints(String s) {
+ if (s.length() == 0) {
+ return null;
+ }
+ final ImmutableList.Builder<Integer> builder = new ImmutableList.Builder<>();
+ final int length = s.length();
+ int i = 0;
+ while (i < length) {
+ int cp = s.codePointAt(i);
+ builder.add(cp);
+ i += cp == s.charAt(i) ? 1 : 2;
+ }
+ return builder.build();
+ }
+
+ /**
+ * SQL TO_CODE_POINTS(binary) function.
Review Comment:
I replace it with `SQL TO_CODE_POINTS(string) function for binary string.`
##########
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})
Review Comment:
Add some comments for three `code_points` functions.
##########
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:
The order of transform will affect the return types.
`INTEGER_NULLABLE.andThen(SqlTypeTransforms.TO_ARRAY)` means: an not null array, which element may be null.
`INTEGER.andThen(SqlTypeTransforms.TO_ARRAY).andThen(SqlTypeTransforms.TO_NULLABLE)` means: an array may be null, but its element is not null.
In `to_code_points` function, we can not get a result like`[1, NULL, 2, 3]`, the element type of array never be `NULL`, so i use `INTEGER` instead of `INTEGER_NULLABLE`.
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1130,14 +1130,68 @@ public static String charFromUtf8(int n) {
assert codePoint instanceof Number;
long cp = ((Number) codePoint).longValue();
if (cp < 0 || cp > 255) {
- throw RESOURCE.inputArgumentsOfCodePointsToBytesOutOfRange(cp).ex();
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange("CODE_POINTS_TO_BYTES", cp).ex();
Review Comment:
I use some keywords like 'out of range' to search whole project, I find only `atanh` function may throw a out of range exception, I replace old code with `inputArgumentsOfFunctionOutOfRange `. And some other "out of range exception" may throw during vaidation phase, I think we don't need to change them.
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] tanclary commented on pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1723659116
@macroguo-ghy No worries, thanks for responding to the comments. I don't have any other suggestions so if you squash your commits I will merge soon assuming no one else has any feedback.
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] tanclary commented on a diff in pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on code in PR #3417:
URL: https://github.com/apache/calcite/pull/3417#discussion_r1321778995
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1130,14 +1130,68 @@ public static String charFromUtf8(int n) {
assert codePoint instanceof Number;
long cp = ((Number) codePoint).longValue();
if (cp < 0 || cp > 255) {
- throw RESOURCE.inputArgumentsOfCodePointsToBytesOutOfRange(cp).ex();
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange("CODE_POINTS_TO_BYTES", cp).ex();
}
bytes[i] = (byte) cp;
}
return new ByteString(bytes);
}
+ /**
+ * SQL CODE_POINTS_TO_STRING function.
+ */
+ public static @Nullable String codePointsToString(List codePoints) {
+ StringBuilder sb = new StringBuilder();
+ for (Object codePoint: codePoints) {
+ if (codePoint == null) {
+ return null;
+ }
+ assert codePoint instanceof Number;
+ long cp = ((Number) codePoint).longValue();
+ // Each valid code point should fall within the range of [0, 0xD7FF] and [0xE000, 0x10FFFF]
+ if (cp >= 0 && cp <= 0xD7FF || cp >= 0xE000 && cp <= 0x10FFFF) {
+ sb.append(charFromUtf8((int) cp));
+ } else {
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange("CODE_POINTS_TO_STRING", cp).ex();
+ }
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * SQL TO_CODE_POINTS(string) function.
+ */
+ public static @Nullable List<Integer> toCodePoints(String s) {
+ if (s.length() == 0) {
+ return null;
+ }
+ final ImmutableList.Builder<Integer> builder = new ImmutableList.Builder<>();
+ final int length = s.length();
+ int i = 0;
+ while (i < length) {
+ int cp = s.codePointAt(i);
+ builder.add(cp);
+ i += cp == s.charAt(i) ? 1 : 2;
+ }
+ return builder.build();
+ }
+
+ /**
+ * SQL TO_CODE_POINTS(binary) function.
Review Comment:
nit: could you check if these javadocs are consistent with other functions that have two signatures (one for strings, one for binary strings)?
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1130,14 +1130,68 @@ public static String charFromUtf8(int n) {
assert codePoint instanceof Number;
long cp = ((Number) codePoint).longValue();
if (cp < 0 || cp > 255) {
- throw RESOURCE.inputArgumentsOfCodePointsToBytesOutOfRange(cp).ex();
+ throw RESOURCE.inputArgumentsOfFunctionOutOfRange("CODE_POINTS_TO_BYTES", cp).ex();
Review Comment:
Would you mind checking if there are other functions that have a similar error (input out of range?)? I think maybe some of the recently added regex functions have a similar error. It could be a good idea to reduce some redundancy if that's the case.
##########
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:
Just a question not a comment: I think the answer is yes, but is there a reason you can't use INTEGER_NULLABLE and then transform it to array? is it due to the ordering?
##########
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})
Review Comment:
Nit: would you mind adding javadocs here? I know not all of the functions have them but given how many functions we've been adding to Calcite recently I think it would be a good practice to have them well-commented.
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en… [calcite]
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary merged PR #3417:
URL: https://github.com/apache/calcite/pull/3417
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1725904459
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3417)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list) [97.9% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] macroguo-ghy commented on a diff in pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en… [calcite]
Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1757440252
Hi @tanclary, could you please review this PR again when you have time? I believe we can merge it before the 1.36.0 release.
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1722389393
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3417)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list) [97.9% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] macroguo-ghy commented on pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "macroguo-ghy (via GitHub)" <gi...@apache.org>.
macroguo-ghy commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1722388454
Hi @tanclary, Thanks for your review, and sorry for late response, I was a litter busy this week. I do some change and add some comments, would you like to review this PR again?
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1712891104
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3417)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list) [98.9% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] tanclary commented on a diff in pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3417: [CALCITE-5993] Add CODE_POINTS_TO_STRING, TO_CODE_POINTS function (en…
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3417:
URL: https://github.com/apache/calcite/pull/3417#issuecomment-1731168067
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3417)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3417&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3417&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list) [98.0% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3417&metric=new_duplicated_lines_density&view=list)
--
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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org