You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/07/29 16:45:22 UTC

[GitHub] [pinot] SabrinaZhaozyf commented on a diff in pull request #9114: Add support for Base64 Encode/Decode Scalar Functions

SabrinaZhaozyf commented on code in PR #9114:
URL: https://github.com/apache/pinot/pull/9114#discussion_r933449964


##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java:
##########
@@ -560,4 +561,24 @@ public static String decodeUrl(String input)
       throws UnsupportedEncodingException {
     return URLDecoder.decode(input, StandardCharsets.UTF_8.toString());
   }
+
+  /**
+   * @param input utf-8 encoded String
+   * @return Base64 encoded String
+   */
+  @ScalarFunction
+  public static String toBase64(String input) {

Review Comment:
   Thanks for the followup! After considering both you and @siddharthteotia 's comments, I propose the following two approaches. Please let me know what you think.
   
   **Method 1 (byte[] to byte[] for both TO_BASE64 and FROM_BASE64)**
   
   - TO_BASE64: byte[] -> base64 encoding -> byte[] =====> user can convert output byte[] to any charset they choose (need to add support for fromASCII and fromUTF8)
   
   - user can convert input string to byte[] using any charset they choose (currently pinot supports toASCII and toUTF8) =====> FROM_BASE64: byte[] -> base64 decoding -> byte[]
   
   **Method 2 (byte[] to String and String to byte[] using user-specified charset)**
   
   - TO_BASE64: byte[] -> base64 encoding -> byte[] -----(user-specified charset)-----> String
   
   - FROM_BASE64: String ----(user-specified charset)--->  byte[] -> base64 decoding -> byte[]
   
   cc: @siddharthteotia @jasperjiaguo 



-- 
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@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org