Skip to content

DataFrame::select_columns doesn't work with names containing "." #3733

@alamb

Description

@alamb

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Put in core/src/dataframe.rs

    #[tokio::test]
    async fn select_with_periods() -> Result<()> {
        // define data with a column name that has a "." in it:
        let array: Int32Array = [1, 10].into_iter().collect();
        let batch =
            RecordBatch::try_from_iter(vec![("f.c1", Arc::new(array) as _)]).unwrap();

        let ctx = SessionContext::new();
        ctx.register_batch("t", batch).unwrap();

        let df = ctx
            .table("t")
            .unwrap()
            .select_columns(&["f.c1"])
            .unwrap();

        let df_results = df.collect().await.unwrap();

        assert_batches_sorted_eq!(
            vec![
                "+------+",
                "| f.c1 |",
                "+------+",
                "| 1    |",
                "| 10   |",
                "+------+",
            ],
            &df_results
        );

        Ok(())
}

Fails like:

thread 'dataframe::tests::select_with_periods' panicked at 'called `Result::unwrap()` on an `Err` value: SchemaError(FieldNotFound { qualifier: Some("f"), name: "c1", valid_fields: Some(["t.f.c1"]) })', datafusion/core/src/dataframe.rs:1437:14

Expected behavior
The test should pass

Additional context
Found while working on #3700

cc @hengfeiyang

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions