hsyuan commented on a change in pull request #1390: [CALCITE-3263] Add MD5/SHA1
SQL functions
URL: https://github.com/apache/calcite/pull/1390#discussion_r315949211
##########
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:
We can go without private `md5_` and `sha1_` method, since they are just
simple function call. You can call them directly in the function.
----------------------------------------------------------------
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