tlfua opened a new issue, #7453: URL: https://github.com/apache/datafusion-comet/issues/7453
### Describe the bug In `read_side_padding.rs`, the three-argument arm (`[Array, Scalar(Int32), Scalar(Utf8)]`) ignores the pad string when the input is a dictionary array. The `Utf8` and `LargeUtf8` branches pass `string` to `spark_read_side_padding_internal`, but both `Dictionary` branches pass `SPACE`. So `rpad`/`lpad` with a custom pad pads with spaces instead. https://github.com/apache/datafusion-comet/blob/644a8708839270d382a78715fca7e2b724143588/native/spark-expr/src/static_invoke/char_varchar_utils/read_side_padding.rs#L115-L132 ### Steps to reproduce Kernel-level, on `main` at 644a87088: ```rust let dict: DictionaryArray<Int32Type> = vec!["ab", "ab"].into_iter().collect(); let args = vec![ ColumnarValue::Array(Arc::new(dict)), ColumnarValue::Scalar(ScalarValue::Int32(Some(5))), ColumnarValue::Scalar(ScalarValue::Utf8(Some("x".to_string()))), ]; spark_rpad(&args) // ["ab ", "ab "] ``` I couldn't find a SQL query that reaches this today. The native scan input unpacks dictionary-encoded strings (see `test_unpack_dictionary_string` in `planner.rs`), and the existing `string_rpad.sql` tests with a custom pad pass. So this looks latent, but it would give silent wrong results if a dictionary array ever reaches the kernel, which is what the `Dictionary` arm (added for SPARK-48498) is there for. ### Expected behavior `["abxxx", "abxxx"]`, the same as for a `Utf8` input. ### Additional context Found while reviewing my change for #7245 (PR #7450). The fix is to pass `string` instead of `SPACE` in the two `Dictionary` branches and add a unit test with a dictionary input and a non-space pad. ### Willingness to contribute I can contribute a fix for this bug independently AI disclosure: this issue was investigated and written with an AI coding assistant, and reviewed by me. -- 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]
