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

Subquery aliases should not be case-sensitive #2358

Closed
Tracked by #474
andygrove opened this issue Apr 27, 2022 · 0 comments · Fixed by #2359
Closed
Tracked by #474

Subquery aliases should not be case-sensitive #2358

andygrove opened this issue Apr 27, 2022 · 0 comments · Fixed by #2359
Assignees
Labels
bug Something isn't working

Comments

@andygrove
Copy link
Member

Describe the bug

SQL identifiers should be case-insensitive unless in double quotes. This is not currently the case for subquery aliases.

To Reproduce

Add this test to datafusion/core/tests/sql/projection.rs

#[tokio::test]
async fn subquery_alias_case_insensitive() -> Result<()> {
    let partition_count = 1;
    let results =
        partitioned_csv::execute("SELECT V1.c1, v1.C2 FROM (SELECT test.C1, TEST.c2 FROM test) V1 ORDER BY v1.c1, V1.C2 LIMIT 1", partition_count).await?;

    let expected = vec![
        "+----+----+",
        "| c1 | c2 |",
        "+----+----+",
        "| 3  | 1  |",
        "+----+----+",
    ];
    assert_batches_sorted_eq!(expected, &results);

    Ok(())
}

Fails with:

Error: Plan("No field named 'v1.c1'. Valid fields are 'V1.c1', 'V1.c2'.")

Expected behavior
SQL planner should normalize the identifier.

Additional context
None

@andygrove andygrove added the bug Something isn't working label Apr 27, 2022
@andygrove andygrove self-assigned this Apr 27, 2022
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