panbingkun commented on code in PR #41689:
URL: https://github.com/apache/spark/pull/41689#discussion_r1241391435
##########
sql/core/src/test/scala/org/apache/spark/sql/MiscFunctionsSuite.scala:
##########
@@ -84,6 +88,152 @@ class MiscFunctionsSuite extends QueryTest with
SharedSparkSession {
}
}
}
+
+ test("uuid") {
+ val df = Seq((1, 2)).toDF("a", "b")
+ assert(df.selectExpr("uuid()").collect() != null)
+ assert(df.select(uuid()).collect() != null)
+ }
+
+ test("aes_encrypt") {
+ val iv = Hex.unhex("000000000000000000000000".getBytes())
+ val df = Seq(("Spark", "abcdefghijklmnop12345678ABCDEFGH",
+ "GCM", "DEFAULT", iv, "This is an AAD mixed into the input")).
+ toDF("input", "key", "mode", "padding", "iv", "aad")
+
+ checkAnswer(
+ df.selectExpr("aes_encrypt(input, key, mode, padding, iv, aad)"),
+ df.select(aes_encrypt(col("input"), col("key"), col("mode"),
+ col("padding"), col("iv"), col("aad"))))
+
+ checkAnswer(
+ df.selectExpr("aes_encrypt(input, key, mode, padding, iv)"),
+ df.select(aes_encrypt(col("input"), col("key"), col("mode"),
+ col("padding"), col("iv"))))
+
+ val df1 = Seq(("Spark SQL", "1234567890abcdef", "ECB", "PKCS")).
+ toDF("input", "key", "mode", "padding")
+
+ checkAnswer(
+ df1.selectExpr("base64(aes_encrypt(input, key, mode, padding))"),
+ df1.select(base64(aes_encrypt(col("input"), col("key"), col("mode"),
col("padding")))))
+
+ val df2 = Seq(("Spark SQL", "0000111122223333", "ECB")).toDF("input",
"key", "mode")
+
+ checkAnswer(
+ df2.selectExpr("hex(aes_encrypt(input, key, mode))"),
+ df2.select(hex(aes_encrypt(col("input"), col("key"), col("mode")))))
+
+ val df3 = Seq(("Spark", "abcdefghijklmnop")).toDF("input", "key")
+ checkAnswer(
+ df3.selectExpr("cast(aes_decrypt(unbase64(base64(" +
+ "aes_encrypt(input, key))), key) AS STRING)"),
+ Seq(Row("Spark")))
+ checkAnswer(
+ df3.select(aes_decrypt(unbase64(base64(
+ aes_encrypt(col("input"), col("key")))), col("key")).cast(StringType)),
+ Seq(Row("Spark")))
+ }
+
+ test("aes_decrypt") {
Review Comment:
@zhengruifeng Do we need merge the test cases for `aes_encrypt ` and
`aes_decrypt `?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]