Skip to content

When joining two tables, get Error: Plan("Schema contains duplicate unqualified field name \'xxx\'") #311

@juaby

Description

@juaby
#[tokio::main]
async fn main() -> Result<()> {
    // create local execution context
    let mut ctx = ExecutionContext::new();

    let testdata = datafusion::arrow::util::test_util::arrow_test_data();

    // register csv file with the execution context
    ctx.register_csv(
        "aggregate_test_100",
        &format!("{}/csv/aggregate_test_100.csv", testdata),
        CsvReadOptions::new(),
    )?;

    ctx.register_csv(
        "aggregate_test_200",
        &format!("{}/csv/aggregate_test_100.csv", testdata),
        CsvReadOptions::new(),
    )?;

    // execute the query
    let df = ctx.sql(
        "SELECT a1.c1, MIN(a1.c12), MAX(a1.c12) \
        FROM aggregate_test_100 a1 left join aggregate_test_200 a2 on a1.c1 = a2.c1  \
        WHERE a1.c11 > 0.1 AND a1.c11 < 0.9 \
        GROUP BY a1.c1 order by a1.c1 limit 2",
    )?;
    let results = df.collect().await?;

    // print the results
    pretty::print_batches(&results)?;

    Ok(())
}

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