Skip to content

Substrait consumer doesn't respect final output column names #10817

@Blizzara

Description

@Blizzara

Describe the bug

Substrait doesn't support the concept of ALIASes, as inside the plan there are no column names, just indices (https://substrait.io/expressions/field_references/#field-references). Ensuring the final plan has the right column names is done through the "names" field on the RootRel.

DataFusion supports already producing that "names" field (

names: plan.schema().field_names(),
), though the produced list lacks the inner names of struct fields (the "names" should be a flattened list of a depth-first search through all the fields). However the consumer side completely disregards the given names (
Ok(from_substrait_rel(ctx, root.input.as_ref().unwrap(), &function_extension).await?)
).

To Reproduce

#[tokio::test]
async fn select_with_alias() -> Result<()> {
    roundtrip("SELECT a AS aliased_a FROM data").await
}

fails with

assertion `left == right` failed
  left: "Projection: data.a AS aliased_a\n  TableScan: data projection=[a]"
 right: "TableScan: data projection=[a]"

Expected behavior

Should succeed producing the correct column names

Additional context

I'll write up a PR to fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions