Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoted schema and table names result in double-quoted names in logical plan. #5058

Closed
neumark opened this issue Jan 25, 2023 · 0 comments · Fixed by #5059
Closed

Quoted schema and table names result in double-quoted names in logical plan. #5058

neumark opened this issue Jan 25, 2023 · 0 comments · Fixed by #5059
Labels
bug Something isn't working

Comments

@neumark
Copy link
Contributor

neumark commented Jan 25, 2023

Description

Quoted schema and table names appear double-quoted in the query plan.

Reproduction

My types of SQL statements are affected, CREATE SCHEMA is just one example:

let sql = "CREATE SCHEMA \"quoted_schema_name\"";
let plan = logical_plan(sql).unwrap();
assert_eq!(format!("{plan:?}"), "CREATE SCHEMA \"\"quoted_schema_name\"\"");

Expected behavior

Quoted identifiers should remain single-quoted (or possibly unquoted if they contain no special characters).

Root cause

The sqlparser create uses ast::Ident (often packaged as ast::ObjectName's) to store identifiers such as table, schema, and column names. Ident stores the actualy identifier in its value field, plus an optional quote character in quoting_style. Ident::to_string() applies the quotes when quoteing_style is not None. The result of Ident::to_string() is once-again quoted by datafusion. For non-quoted identifiers only the second quoting is applied, masking the bug.

Since datafusion does it's own quoting, Ident::to_string() calls should be replaced by ident.value.

Example occurance: Ident::toString() usage for CREATE SCHEMA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant