Omega359 commented on PR #22169:
URL: https://github.com/apache/datafusion/pull/22169#issuecomment-4527233982

   I had codex review this PR. Here is it's findings and the tests it ran to 
verify:
   ```
   Findings: None. I did not find a correctness issue or a missing-test gap 
that I would block on.
   I focused on the new DISTINCT ON planner paths through aggregation, windows, 
aliases, hidden sort keys, and unnest rewriting. I also ran self-contained 
sqllogictest cases for:
   
   • DISTINCT ON after QUALIFY with window output
   • DISTINCT ON referencing a window alias
   • nested alias/name-conflict behavior after aggregation
   • global aggregate DISTINCT ON, including aggregate alias use
   Those focused cases passed. 
   ```
   
   ```
   query II
   WITH t(a,b) AS (VALUES (1,10),(1,20),(1,30),(2,40),(2,50))
   SELECT DISTINCT ON (a) a, row_number() OVER (PARTITION BY a ORDER BY b) AS rn
   FROM t
   QUALIFY rn > 1
   ORDER BY a, rn;
   ----
   1 2
   2 2
   
   query II
   WITH t(a,b) AS (VALUES (1,10),(1,20),(1,30),(2,40),(2,50))
   SELECT DISTINCT ON (rn) a, row_number() OVER (PARTITION BY a ORDER BY b) AS 
rn
   FROM t
   ORDER BY rn, a;
   ----
   1 1
   1 2
   1 3
   
   query II
   WITH t(a,b) AS (VALUES (100,1),(100,2),(200,1))
   SELECT DISTINCT ON (b + 0) a AS b, sum(b) AS s
   FROM t GROUP BY a,b ORDER BY b + 0 DESC, a DESC;
   ----
   100 2
   200 1
   
   query I
   WITH t(a,b) AS (VALUES (1,10),(2,20))
   SELECT DISTINCT ON (max(b)) max(b) FROM t ORDER BY max(b);
   ----
   20
   
   query I
   WITH t(a,b) AS (VALUES (1,10),(2,20))
   SELECT DISTINCT ON (total) max(b) AS total FROM t ORDER BY total;
   ----
   20
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to