Skip to content

fail to sql query if column contains capitalized letter #399

Description

@hu6360567

Describe the bug
fail to execute sql when select with column if the column contains capitalized letter

To Reproduce

import pyarrow as pa
import datafusion

if __name__ == "__main__":
    tbl = pa.Table.from_arrays([[1, 2, 3]], names=["id"])

    for column_name in ["id", "ID", "iD"]:
        ctx = datafusion.SessionContext()
        ctx.register_record_batches(name="tbl", partitions=[tbl.rename_columns([column_name]).to_batches()])

        sql = f"SELECT {column_name} from tbl"


        try:
            print(sql)
            ctx.sql(sql)
        except Exception as e:
            print(e)
SELECT id from tbl
SELECT ID from tbl
DataFusion error: SchemaError(FieldNotFound { field: Column { relation: None, name: "id" }, valid_fields: [Column { relation: Some(Bare { table: "tbl" }), name: "ID" }] })
SELECT iD from tbl
DataFusion error: SchemaError(FieldNotFound { field: Column { relation: None, name: "id" }, valid_fields: [Column { relation: Some(Bare { table: "tbl" }), name: "iD" }] })

Expected behavior
All sql should executed successfully.

Additional context
Python 3.8.16
pyarrow 12.0.0
datafusion 23.0.0

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions