-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When creating a logical plan using SqlToRel with options that do not enable_ident_normalization, identifiers still end up getting normalized in some cases.
To Reproduce
let sql = "SELECT UPPERCASE from test";
let dialect = GenericDialect {};
let ast = Parser::parse_sql(&dialect, sql).unwrap();
let statement = &ast[0];
let schema_provider = MySchemaProvider::new();
let options = ParserOptions {
parse_float_as_decimal: false,
enable_ident_normalization: false,
};
let sql_to_rel = SqlToRel::new_with_options(&schema_provider, options);
let plan = sql_to_rel.sql_statement_to_plan(statement.clone()).unwrap();
println!("{plan:?}");Where MySchemaProvider has the following
tables.insert(
"test".to_string(),
create_table_source(vec![Field::new("UPPERCASE", DataType::Int32, false)]),
);Leads to:
SchemaError(FieldNotFound { field: Column { relation: None, name: "uppercase" }, valid_fields: [Column { relation: Some(Bare { table: "test" }), name: "UPPERCASE" }] })'
Definition of everything else is taken from this example.
Expected behavior
When enable_ident_normalization is false, the identified UPPERCASE shouldn't be normalized to uppercase.
Additional context
Looks like this particular case stems from https://github.com/apache/arrow-datafusion/blob/36fe9745407351277649ce07a12f036a2bb653a5/datafusion/sql/src/expr/identifier.rs#L46-L48
but generally a few places use utils::normalize_ident instead of planner::normalize_ident.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working