ILuffZhe commented on code in PR #4176:
URL: https://github.com/apache/calcite/pull/4176#discussion_r1938387820
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -330,6 +330,28 @@ private static String toBase64_(byte[] bytes) {
}
}
+ /** SQL BASE64(string) function for string. */
+ public static String base64(String string) {
Review Comment:
There already exists `toBase64(ByteString string)` and `toBase64(String
string)` in SqlFunctions.
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -330,6 +330,28 @@ private static String toBase64_(byte[] bytes) {
}
}
+ /** SQL BASE64(string) function for string. */
+ public static String base64(String string) {
+ return toBase64_(string.getBytes(UTF_8));
+ }
+
+ /** SQL BASE64(string) function for bytestring. */
+ public static String base64(ByteString byteString) {
+ byte[] bytes = byteString.getBytes();
+ return toBase64_(bytes);
+ }
+
+ /** SQL UNBASE64(string) function. */
+ public static @Nullable String unBase64(String base64) {
+ try {
+ base64 = FROM_BASE64_REGEXP.matcher(base64).replaceAll("");
+ //CHECKSTYLE: IGNORE 1
Review Comment:
What's this comment for?
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -330,6 +330,28 @@ private static String toBase64_(byte[] bytes) {
}
}
+ /** SQL BASE64(string) function for string. */
+ public static String base64(String string) {
+ return toBase64_(string.getBytes(UTF_8));
+ }
+
+ /** SQL BASE64(string) function for bytestring. */
+ public static String base64(ByteString byteString) {
+ byte[] bytes = byteString.getBytes();
+ return toBase64_(bytes);
+ }
+
+ /** SQL UNBASE64(string) function. */
+ public static @Nullable String unBase64(String base64) {
Review Comment:
Can we make it return String, so `ByteString fromBase64(String base64)` can
be used.
--
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]