Vedin commented on issue #17210:
URL: https://github.com/apache/datafusion/issues/17210#issuecomment-3220355903

   > Hello! I've opened 
[#17313](https://github.com/apache/datafusion/pull/17313) that should fix the 
aggregate problem.
   > 
   > As for the second concern, the example provided works with the original 
`QUALIFY` implementation. Maybe we can add some more context regarding the 
specific problem?
   > 
   > Thanks!
   
   Yeah, the provided example really works for me as well, but there are still 
some problems with `common_sub_expression_eliminate` rule. I have tried this 
example with your changes, and it appears to be failing. So, reproducible is:
   ```sql
   CREATE TABLE bulk_import_entities (
     id INT,
     _task_instance INT,
     _uploaded_at TIMESTAMP
   ) AS VALUES
     (1, 1, '2025-01-01 10:00:00'::timestamp),
     (1, 2, '2025-01-02 09:00:00'::timestamp),
     (1, 2, '2025-01-03 08:00:00'::timestamp),
     (2, 1, '2025-01-01 11:00:00'::timestamp),
     (2, 2, '2025-01-02 12:00:00'::timestamp),
     (3, 1, '2025-01-01 13:00:00'::timestamp);
   
   SELECT id, _task_instance
   FROM bulk_import_entities
   WHERE _task_instance = (
     SELECT MAX(_task_instance) FROM bulk_import_entities
   )
   QUALIFY ROW_NUMBER() OVER (PARTITION BY id ORDER BY _uploaded_at) = 1
   ORDER BY id;
   ```
   with error: 
   ```
   Optimizer rule 'common_sub_expression_eliminate' failed
   caused by
   Error during planning: Window has mismatch between number of expressions (1) 
and number of fields in schema (0)
   ```
   While the correct output is 
   ```
   1 2
   2 2
   ```
   


-- 
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

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