epsio-banay opened a new issue, #13038:
URL: https://github.com/apache/datafusion/issues/13038

   ### 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:
   
   ```
   #[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_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to