This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 4cc0b51bddb5 [SPARK-53806][SQL] Allow empty input on AES decrypt to
have error class
4cc0b51bddb5 is described below
commit 4cc0b51bddb5710f743f30dd4995e15d73a74cc3
Author: Richard Chen <[email protected]>
AuthorDate: Wed Oct 8 08:20:47 2025 -0700
[SPARK-53806][SQL] Allow empty input on AES decrypt to have error class
### What changes were proposed in this pull request?
also catch IllegalArgumentException for AES encrypt/decrypt expressions
### Why are the changes needed?
previously, if empty input is given to AES decrypt, it would return the
error
```
IllegalArgumentException: Invalid buffer arguments
```
Now, with this change,
```
SparkRuntimeException: [INVALID_PARAMETER_VALUE.AES_KEY] The value of
parameter(s) `expr`, `key` in `aes_encrypt`/`aes_decrypt` is invalid: detail
message: Invalid buffer arguments
```
### Does this PR introduce _any_ user-facing change?
yes - see above. Error message change
### How was this patch tested?
added UT
### Was this patch authored or co-authored using generative AI tooling?
no
Closes #52523 from richardc-db/fix_error_class_in_aes_decrypt_empty_input.
Authored-by: Richard Chen <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
.../spark/sql/catalyst/expressions/ExpressionImplUtils.java | 2 +-
.../sql/catalyst/expressions/ExpressionImplUtilsSuite.scala | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git
a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
index 8c42e5bf112c..a5228edc33c8 100644
---
a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
+++
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java
@@ -274,7 +274,7 @@ public class ExpressionImplUtils {
return cipher.doFinal(input, 0, input.length);
}
}
- } catch (GeneralSecurityException e) {
+ } catch (GeneralSecurityException | IllegalArgumentException e) {
throw QueryExecutionErrors.aesCryptoError(e.getMessage());
}
}
diff --git
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtilsSuite.scala
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtilsSuite.scala
index 25b647baf7b6..e197c71026eb 100644
---
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtilsSuite.scala
+++
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtilsSuite.scala
@@ -325,6 +325,19 @@ class ExpressionImplUtilsSuite extends SparkFunSuite {
"functionName" -> "`aes_encrypt`/`aes_decrypt`",
"detailMessage" -> "Tag mismatch[!]?"
)
+ ),
+ // Empty input
+ TestCase(
+ "Spark",
+ "abcdefghijklmnop12345678ABCDEFGH",
+ "",
+ "GCM",
+ expectedErrorClassOpt = Some("INVALID_PARAMETER_VALUE.AES_CRYPTO_ERROR"),
+ errorParamsMap = Map(
+ "parameter" -> "`expr`, `key`",
+ "functionName" -> "`aes_encrypt`/`aes_decrypt`",
+ "detailMessage" -> "Invalid buffer arguments"
+ )
)
)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]