-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
A-sqlArea: Polars SQL functionalityArea: Polars SQL functionalityneeds triageAwaiting prioritization by a maintainerAwaiting prioritization by a maintainerrustRelated to Rust PolarsRelated to Rust Polars
Description
Checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of Polars.
Reproducible example
use polars::sql::SQLContext;
fn main() {
let mut ctx = SQLContext::new();
let query = r#"
WITH a AS (
SELECT 0 AS k
), b AS (
SELECT 0 AS k
), c AS (
SELECT 0 AS k
)
SELECT k FROM a JOIN c on a.k = c.k
UNION ALL
SELECT k FROM b JOIN c on b.k = c.k
"#;
println!("Executing SQL query:");
println!("{query}");
println!();
match ctx.execute(query) {
Ok(lf) => {
println!("Query executed successfully!");
let result = lf.collect().unwrap();
println!("Result:\n{result}");
}
Err(e) => {
println!("ERROR: {e}");
}
}
}Log output
ERROR: not found: unable to find column "k:c"; valid columns: ["k"]
Resolved plan until failure:
---> FAILED HERE RESOLVING 'join' <---
SELECT [col("k")]
WITH_COLUMNS:
[dyn int: 0.alias("k")]
DF []; PROJECT */0 COLUMNSIssue description
Seems like there's a problem in how polars SQL engine handles ambiguous column names in UNION ALL + JOIN contexts
Expected behavior
Should not fail, return 2 zeros
Installed versions
Details
polars = { git = "https://github.com/pola-rs/polars", rev = "40d7a8cf70d1294f98a9b717bb7340957cc80591", features = [
"sql",
] }
mmosyagin-pinely
Metadata
Metadata
Assignees
Labels
A-sqlArea: Polars SQL functionalityArea: Polars SQL functionalityneeds triageAwaiting prioritization by a maintainerAwaiting prioritization by a maintainerrustRelated to Rust PolarsRelated to Rust Polars