feat(spark): implement StringView for SparkConcat#19984
Merged
Jefffrey merged 4 commits intoapache:mainfrom Jan 27, 2026
Merged
feat(spark): implement StringView for SparkConcat#19984Jefffrey merged 4 commits intoapache:mainfrom
StringView for SparkConcat#19984Jefffrey merged 4 commits intoapache:mainfrom
Conversation
fc92fa6 to
e052fa3
Compare
StringView for SparkConcatStringView for SparkConcat
Weijun-H
reviewed
Jan 25, 2026
Member
Weijun-H
left a comment
There was a problem hiding this comment.
LGTM, thanks @aryan-212 👍
It is better to add some mixed type tests
# Test mixed types: Utf8View + Utf8
query T
SELECT concat(arrow_cast('hello', 'Utf8View'), ' world');
----
hello world
# Test all three types mixed together
query T
SELECT concat('a', arrow_cast('b', 'LargeUtf8'), arrow_cast('c', 'Utf8View'));
----
abc
d791634 to
9329a43
Compare
Contributor
Author
|
Added them @Weijun-H, thanks for reviewing 🙇 |
Jefffrey
reviewed
Jan 25, 2026
ad92725 to
7bb3ba0
Compare
7bb3ba0 to
02362fe
Compare
Jefffrey
reviewed
Jan 25, 2026
1c997dc to
28156b8
Compare
Contributor
Author
|
@Jefffrey , made the required test changes. Please have a look 🙇 |
Jefffrey
approved these changes
Jan 25, 2026
3715990 to
577b604
Compare
577b604 to
1358178
Compare
Contributor
|
Thanks @aryan-212 & @Weijun-H |
de-bgunter
pushed a commit
to de-bgunter/datafusion
that referenced
this pull request
Mar 24, 2026
## 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 apache#123` indicates that this PR will close issue apache#123. --> - This PR is part of the [Utf8View support](apache#10918) epic. It adds `Utf8View` support in the Spark-compat layer. ## Rationale for this change In our internal project we're only suppporting `Utf8View` _(because of design constraints)_ and the current implementation of `SparkConcat` only supports `Utf8`. The `SparkConcat` function should accept `Utf8View` and mixed string types in line with the main DataFusion concat. This PR adds that support and follows the same patterns as [DataFusion’s concat](https://github.com/apache/datafusion/blob/main/datafusion/functions/src/string/concat.rs). Prevents errors like : > The type of Utf8 AND Utf8View of like physical should be same. > This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues from a query like:- ```sql select i_item_sk, item_info from (select i_item_sk, CONCAT('Item: ', i_item_desc) as item_info from item) sub where item_info LIKE 'Item: Electronic%' order by 1; ``` ## What changes are included in this PR? - Extend the type signature to accept `Utf8View` in addition to `Utf8` and `LargeUtf8` via `TypeSignature::Variadic(vec![Utf8View, Utf8, LargeUtf8])` matching DataFusion’s concat. - In `return_field_from_args`, compute the result type with precedence Utf8View > LargeUtf8 > Utf8. In spark_concat, handle Utf8View and LargeUtf8 in scalar paths (zero-argument and all-NULL). ## Are these changes tested? Yes. - Unit tests: `cargo test --package datafusion-spark function::string::concat::tests`, including `test_concat_utf8view`. - Sqllogictest: `spark/string/concat.slt` includes a “**Utf8View: no extra CAST in plan**” case that uses EXPLAIN and a temporary table to ensure no extra CASTs when using arrow_cast(..., 'Utf8View') with table columns. ## Are there any user-facing changes? - **API:** SparkConcat’s signature is extended to include Utf8View in the variadic list. No breaking changes. _used gpt to rephrase some of these points_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Utf8Viewsupport in the Spark-compat layer.Rationale for this change
In our internal project we're only suppporting
Utf8View(because of design constraints) and the current implementation ofSparkConcatonly supportsUtf8. TheSparkConcatfunction should acceptUtf8Viewand mixed string types in line with the main DataFusion concat. This PR adds that support and follows the same patterns as DataFusion’s concat.Prevents errors like :
from a query like:-
What changes are included in this PR?
Extend the type signature to accept
Utf8Viewin addition toUtf8andLargeUtf8viaTypeSignature::Variadic(vec![Utf8View, Utf8, LargeUtf8])matching DataFusion’s concat.In
return_field_from_args, compute the result type with precedence Utf8View > LargeUtf8 > Utf8.In spark_concat, handle Utf8View and LargeUtf8 in scalar paths (zero-argument and all-NULL).
Are these changes tested?
Yes.
cargo test --package datafusion-spark function::string::concat::tests, includingtest_concat_utf8view.spark/string/concat.sltincludes a “Utf8View: no extra CAST in plan” case that uses EXPLAIN and a temporary table to ensure no extra CASTs when using arrow_cast(..., 'Utf8View') with table columns.Are there any user-facing changes?
used gpt to rephrase some of these points