This is an automated email from the ASF dual-hosted git repository.
richox pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/auron.git
The following commit(s) were added to refs/heads/master by this push:
new 9d0bbd35 [AURON #1710] Fix string_lower only supports literal utf8
(#1714)
9d0bbd35 is described below
commit 9d0bbd350b9993c57b8fad590bebe7a6a72b88df
Author: cxzl25 <[email protected]>
AuthorDate: Wed Dec 17 19:41:07 2025 +0800
[AURON #1710] Fix string_lower only supports literal utf8 (#1714)
<!--
Thanks for sending a pull request! Please keep the following tips in
mind:
- Start the PR title with the related issue ID, e.g. '[AURON #XXXX]
Short summary...'.
- Make your PR title clear and descriptive, summarizing what this PR
changes.
- Provide a concise example to reproduce the issue, if possible.
- Keep the PR description up to date with all changes.
-->
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
Closes #1710
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
# How was this patch tested?
1. Add UT
2. SQL validation in production environment
---
.../datafusion-ext-functions/src/spark_strings.rs | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/native-engine/datafusion-ext-functions/src/spark_strings.rs
b/native-engine/datafusion-ext-functions/src/spark_strings.rs
index 7e0cd4e4..809e826e 100644
--- a/native-engine/datafusion-ext-functions/src/spark_strings.rs
+++ b/native-engine/datafusion-ext-functions/src/spark_strings.rs
@@ -38,6 +38,9 @@ pub fn string_lower(args: &[ColumnarValue]) ->
Result<ColumnarValue> {
ColumnarValue::Scalar(ScalarValue::Utf8(Some(str))) =>
Ok(ColumnarValue::Scalar(
ScalarValue::Utf8(Some(str.to_lowercase())),
)),
+ ColumnarValue::Scalar(ScalarValue::Utf8(None)) => {
+ Ok(ColumnarValue::Scalar(ScalarValue::Utf8(None)))
+ }
_ => df_execution_err!("string_lower only supports literal utf8"),
}
}
@@ -52,6 +55,9 @@ pub fn string_upper(args: &[ColumnarValue]) ->
Result<ColumnarValue> {
ColumnarValue::Scalar(ScalarValue::Utf8(Some(str))) =>
Ok(ColumnarValue::Scalar(
ScalarValue::Utf8(Some(str.to_uppercase())),
)),
+ ColumnarValue::Scalar(ScalarValue::Utf8(None)) => {
+ Ok(ColumnarValue::Scalar(ScalarValue::Utf8(None)))
+ }
_ => df_execution_err!("string_upper only supports literal utf8"),
}
}
@@ -324,6 +330,7 @@ mod test {
},
physical_plan::ColumnarValue,
};
+ use datafusion_ext_commons::df_execution_err;
use crate::spark_strings::{
string_concat, string_concat_ws, string_lower, string_repeat,
string_space, string_split,
@@ -370,6 +377,24 @@ mod test {
Ok(())
}
+ #[test]
+ fn test_string_lower_null_scalar() -> Result<()> {
+ let r =
string_lower(&vec![ColumnarValue::Scalar(ScalarValue::Utf8(None))])?;
+ match r {
+ ColumnarValue::Scalar(ScalarValue::Utf8(None)) => Ok(()),
+ other => df_execution_err!("Expected null Utf8 scalar, got: {:?}",
other),
+ }
+ }
+
+ #[test]
+ fn test_string_upper_null_scalar() -> Result<()> {
+ let r =
string_upper(&vec![ColumnarValue::Scalar(ScalarValue::Utf8(None))])?;
+ match r {
+ ColumnarValue::Scalar(ScalarValue::Utf8(None)) => Ok(()),
+ other => df_execution_err!("Expected null Utf8 scalar, got: {:?}",
other),
+ }
+ }
+
#[test]
fn test_string_repeat() -> Result<()> {
// positive case