Skip to content

DFSchema::check_names allows ambiguous references. #11464

@aalexandrov

Description

@aalexandrov

Describe the bug

Constructing a schema with duplicate identical qualified names does not produce an error. I think it should, or we should extend the documentation of DFSchema::check_names to explain why those are allowed and where they are needed.

To Reproduce

use arrow_schema::{DataType, Field};
use datafusion_common::DFSchema;
use datafusion_sql::TableReference;
use std::sync::Arc;


#[test]
fn df_schema_check() {
    let t = || TableReference::bare("t");
    let schema = DFSchema::new_with_metadata(
        vec![
            (Some(t()), Arc::new(Field::new("a", DataType::Int64, true))),
            (Some(t()), Arc::new(Field::new("a", DataType::Utf8, false))),
        ],
        Default::default(),
    );
    schema.expect_err("duplicate t.a columns");
}

Expected behavior

Reading through the comments, I would expect to see an error thrown by the join method in this case.

Additional context

I found this while working on #11456.

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