Skip to content

Inconsistent datafusion.sql_parser.enable_ident_normalization=false behaviour #18675

@milenkovicm

Description

@milenkovicm

Describe the bug

There is inconsistency with datafusion.sql_parser.enable_ident_normalization, when set to false, disabling normalisation.

To Reproduce

use datafusion::{error::Result, prelude::SessionContext};

#[tokio::main]
async fn main() -> Result<()> {
    let ctx = SessionContext::new();

    ctx.sql("SET datafusion.sql_parser.enable_ident_normalization=false")
        .await?
        .collect()
        .await?;

    ctx.register_csv(
        "DATA",
        "data.csv",
        Default::default(),
    )
    .await?;

    ctx.sql("select * from DATA").await?.show().await?;

    Ok(())
}

(note all caps table name DATA)

will fail with error:

Error: Diagnostic(Diagnostic { kind: Error, message: "table 'DATA' not found", span: Some(Span(Location(1,15)..Location(1,19))), notes: [], helps: [] }, Plan("table 'datafusion.public.DATA' not found"))

Expected behavior

Expected behaviour would be to find table datafusion.public.DATA.

I'm not sure if DATA (name) should be normalised to lower-case, I would argue not, but some consistency is needed.

Additional context

Issue starts at register_csv table (actually, register_table) where table name is converted to lover case at:

https://github.com/milenkovicm/datafusion/blob/377c0fce481d561d58e3a6fad2dca18cb1d58384/datafusion/core/src/execution/context/mod.rs#L1609-L1610

root of the issue is at:

Self::parse_str_normalized(s, false)

where normalisation is enforced as second parameter is false (based on docs)

EDIT: there is workaround to make this working, adding quotes to table name will do the trick

ctx.register_csv( "`DATA`", "data.csv",Default::default(),).await?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions