This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 1825f97b76 Add duplicate name error reproducer (#20106)
1825f97b76 is described below
commit 1825f97b7669976c1b497992598c32e2d5db8563
Author: Gabriel <[email protected]>
AuthorDate: Tue Feb 3 10:09:11 2026 +0100
Add duplicate name error reproducer (#20106)
## 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 #.
## 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.
-->
Reproduces a duplicate name issue introduced in
https://github.com/apache/datafusion/pull/19019.
Reverting the following code:
https://github.com/apache/datafusion/blob/2e02cc131d1d71cce819000912f0411345ca2d6e/datafusion/expr/src/expr_rewriter/mod.rs#L263-L263
From:
```rust
_ => {
// maintain the original name when casting
let name = dst_schema.field(idx).name();
Ok(expr.cast_to(new_type, src_schema)?.alias(name))
}
```
to
```rust
_ => expr.cast_to(new_type, src_schema),
```
Seems to fix the issue.
TODO: actually fix the issue before merging
## 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.
-->
For now, just a reproducer test
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
yes, by a new test
## Are there any user-facing changes?
no
<!--
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.
-->
---
datafusion/substrait/tests/cases/logical_plans.rs | 27 ++++
.../duplicate_name_in_union.substrait.json | 171 +++++++++++++++++++++
2 files changed, 198 insertions(+)
diff --git a/datafusion/substrait/tests/cases/logical_plans.rs
b/datafusion/substrait/tests/cases/logical_plans.rs
index 5ebacaf533..115c598430 100644
--- a/datafusion/substrait/tests/cases/logical_plans.rs
+++ b/datafusion/substrait/tests/cases/logical_plans.rs
@@ -229,4 +229,31 @@ mod tests {
Ok(())
}
+
+ #[tokio::test]
+ // Test still failing, issue tracked in
"https://github.com/apache/datafusion/issues/20123".
+ #[ignore]
+ async fn duplicate_name_in_union() -> Result<()> {
+ let proto_plan =
+
read_json("tests/testdata/test_plans/duplicate_name_in_union.substrait.json");
+ let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan)?;
+ let plan = from_substrait_plan(&ctx.state(), &proto_plan).await?;
+
+ assert_snapshot!(
+ plan,
+ @r"
+ Projection: foo AS col1, bar AS col2
+ Union
+ Projection: foo, bar
+ Values: (Int64(100), Int64(200))
+ Projection: x, foo
+ Values: (Int32(300), Int64(400))
+ "
+ );
+
+ // Trigger execution to ensure plan validity
+ DataFrame::new(ctx.state(), plan).show().await?;
+
+ Ok(())
+ }
}
diff --git
a/datafusion/substrait/tests/testdata/test_plans/duplicate_name_in_union.substrait.json
b/datafusion/substrait/tests/testdata/test_plans/duplicate_name_in_union.substrait.json
new file mode 100644
index 0000000000..1da2ff6131
--- /dev/null
+++
b/datafusion/substrait/tests/testdata/test_plans/duplicate_name_in_union.substrait.json
@@ -0,0 +1,171 @@
+{
+ "version": {
+ "minorNumber": 54,
+ "producer": "datafusion-test"
+ },
+ "relations": [
+ {
+ "root": {
+ "input": {
+ "set": {
+ "common": {
+ "direct": {}
+ },
+ "inputs": [
+ {
+ "project": {
+ "common": {
+ "emit": {
+ "outputMapping": [2, 3]
+ }
+ },
+ "input": {
+ "read": {
+ "common": {
+ "direct": {}
+ },
+ "baseSchema": {
+ "names": ["foo", "bar"],
+ "struct": {
+ "types": [
+ {
+ "i64": {
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ },
+ {
+ "i64": {
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ }
+ ],
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ },
+ "virtualTable": {
+ "expressions": [
+ {
+ "fields": [
+ {
+ "literal": {
+ "i64": "100"
+ }
+ },
+ {
+ "literal": {
+ "i64": "200"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ "expressions": [
+ {
+ "selection": {
+ "directReference": {
+ "structField": {
+ "field": 0
+ }
+ },
+ "rootReference": {}
+ }
+ },
+ {
+ "selection": {
+ "directReference": {
+ "structField": {
+ "field": 1
+ }
+ },
+ "rootReference": {}
+ }
+ }
+ ]
+ }
+ },
+ {
+ "project": {
+ "common": {
+ "emit": {
+ "outputMapping": [2, 3]
+ }
+ },
+ "input": {
+ "read": {
+ "common": {
+ "direct": {}
+ },
+ "baseSchema": {
+ "names": ["x", "foo"],
+ "struct": {
+ "types": [
+ {
+ "i32": {
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ },
+ {
+ "i64": {
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ }
+ ],
+ "nullability": "NULLABILITY_REQUIRED"
+ }
+ },
+ "virtualTable": {
+ "expressions": [
+ {
+ "fields": [
+ {
+ "literal": {
+ "i32": 300
+ }
+ },
+ {
+ "literal": {
+ "i64": "400"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ "expressions": [
+ {
+ "selection": {
+ "directReference": {
+ "structField": {
+ "field": 0
+ }
+ },
+ "rootReference": {}
+ }
+ },
+ {
+ "selection": {
+ "directReference": {
+ "structField": {
+ "field": 1
+ }
+ },
+ "rootReference": {}
+ }
+ }
+ ]
+ }
+ }
+ ],
+ "op": "SET_OP_UNION_ALL"
+ }
+ },
+ "names": ["col1", "col2"]
+ }
+ }
+ ]
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]