Skip to content

[Rust][DataFusion] Join Statement: Schema contains duplicate unqualified field name #9307

Closed

Description

@gangliao

@Dandandan

"Schema contains duplicate unqualified field name \'a\'")
thread 'tests::simple_join' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure'
      let schema1 = Arc::new(Schema::new(vec![
            Field::new("a", DataType::Utf8, false),
            Field::new("b", DataType::Int32, false),
        ]));
        let schema2 = Arc::new(Schema::new(vec![
            Field::new("a", DataType::Utf8, false),
            Field::new("d", DataType::Int32, false),
        ]));

        // define data.
        let batch1 = RecordBatch::try_new(
            schema1.clone(),
            vec![
                Arc::new(StringArray::from(vec!["a", "b", "c", "d"])),
                Arc::new(Int32Array::from(vec![1, 10, 10, 100])),
            ],
        )?;
        // define data.
        let batch2 = RecordBatch::try_new(
            schema2.clone(),
            vec![
                Arc::new(StringArray::from(vec!["a", "b", "c", "d"])),
                Arc::new(Int32Array::from(vec![1, 10, 10, 100])),
            ],
        )?;

        let mut ctx = ExecutionContext::new();

        let table1 = MemTable::try_new(schema1, vec![vec![batch1]])?;
        let table2 = MemTable::try_new(schema2, vec![vec![batch2]])?;

        ctx.register_table("t1", Box::new(table1));
        ctx.register_table("t2", Box::new(table2));

        let sql = concat!(
            "SELECT a, b, d ",
            "FROM t1 JOIN t2 ON t1.a = t2.a ",
            "ORDER BY b ASC ",
            "LIMIT 3"
        );

        let plan = ctx.create_logical_plan(&sql)?;
        let plan = ctx.optimize(&plan)?;
        let plan = ctx.create_physical_plan(&plan)?;

Activity

  1. Dandandan commented on Jan 24, 2021

    @Dandandan
    Contributor

    @gangliao I believe this is a SQL error, the a is ambiguous in the projection. Could you try: SELECT t1.a as a, b, d?

  2. gangliao commented on Jan 24, 2021

    @gangliao
    Author

    I tried two solutions:

            let sql = concat!(
                "SELECT b, d ",
                "FROM t1 JOIN t2 ON t1.a = t2.a ",
                "ORDER BY b ASC ",
                "LIMIT 3"
            );
    
            let sql = concat!(
                "SELECT t1.a as a, b, d ",
                "FROM t1 JOIN t2 ON t1.a = t2.a ",
                "ORDER BY b ASC ",
                "LIMIT 3"
            );

    But I still got the same error.

    Schema contains duplicate unqualified field name \'a\'")
    thread 'tests::simple_join' panicked at 'assertion failed: `(left == right)`
      left: `1`,
     right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure'
  3. jorgecarleitao commented on Jan 29, 2021

    @jorgecarleitao
    Member

    Seems like a bug to me. :( Could you add it to JIRA?

  4. gangliao commented on Jan 29, 2021

    @gangliao
    Author

    Sure.

  5. emkornfield commented on Jan 30, 2021

    @emkornfield
    Contributor

    going to close this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions