LiShuMing commented on a change in pull request #1390: [CALCITE-3263] Add 
MD5/SHA1 SQL functions
URL: https://github.com/apache/calcite/pull/1390#discussion_r315978913
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##########
 @@ -172,6 +173,34 @@ public static ByteString fromBase64(String base64) {
     }
   }
 
+  /** SQL MD5(string) function. */
+  public static @Nonnull String md5(@Nonnull String string)  {
+    return md5_(string.getBytes(UTF_8));
+  }
+
+  /** SQL MD5(string) function for binary string. */
+  public static @Nonnull String md5(@Nonnull ByteString string)  {
+    return md5_(string.getBytes());
+  }
+
+  private static @Nonnull String md5_(byte[] bytes)  {
+    return DigestUtils.md5Hex(bytes);
+  }
 
 Review comment:
   Hi @hsuanyi , thanks for your replies. I have upgraded my codes as your 
advise.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to