You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When planning a query with distinct on, the distinct on expressions must match the order by expressions.
There is a check for that, however the check checks if the expressions are equal without normalizing column names first.
Because of that planning queries like "SELECT DISTINCT ON (t.a) * FROM t ORDER BY a" won't work while ""SELECT DISTINCT ON (t.a) * FROM t ORDER BY t.a" will.
To Reproduce
Add the following to plan.rs unit tests and run:
#[test]
fn distinct_on_expr_order_by_match() -> Result<()> {
let schema = Schema::new(vec![Field::new("a", DataType::Int32, false)]);
let table_scan =
table_scan(Some(TableReference::bare("t")), &schema, None)?.build()?;
let p = DistinctOn::try_new(
vec![col("a")],
vec![],
Some(vec![SortExpr::new(col("t.a"), true, false)]),
Arc::new(table_scan),
)?;
Ok(())
}
Expected behavior
Test should pass
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
When planning a query with distinct on, the distinct on expressions must match the order by expressions.
There is a check for that, however the check checks if the expressions are equal without normalizing column names first.
Because of that planning queries like "SELECT DISTINCT ON (t.a) * FROM t ORDER BY a" won't work while ""SELECT DISTINCT ON (t.a) * FROM t ORDER BY t.a" will.
To Reproduce
Add the following to plan.rs unit tests and run:
Expected behavior
Test should pass
Additional context
No response
The text was updated successfully, but these errors were encountered: