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
Add support for functional dependency for ROW_NUMBER window function. (#8737)
* Add primary key support for row_number window function
* Add comments, minor changes
* Add new test
* Review
---------
Co-authored-by: Mehmet Ozan Kabak <[email protected]>
Copy file name to clipboardexpand all lines: datafusion/sqllogictest/test_files/window.slt
+39-1
Original file line number
Diff line number
Diff line change
@@ -3832,4 +3832,42 @@ select row_number() over (partition by 1 order by 1) rn,
3832
3832
from (select 1 a union all select 2 a) x;
3833
3833
----
3834
3834
1 1 1 1 1 1
3835
-
2 1 1 2 2 1
3835
+
2 1 1 2 2 1
3836
+
3837
+
# when partition by expression is empty row number result will be unique.
3838
+
query TII
3839
+
SELECT *
3840
+
FROM (SELECT c1, c2, ROW_NUMBER() OVER() as rn
3841
+
FROM aggregate_test_100
3842
+
LIMIT 5)
3843
+
GROUP BY rn
3844
+
ORDER BY rn;
3845
+
----
3846
+
c 2 1
3847
+
d 5 2
3848
+
b 1 3
3849
+
a 1 4
3850
+
b 5 5
3851
+
3852
+
# when partition by expression is constant row number result will be unique.
3853
+
query TII
3854
+
SELECT *
3855
+
FROM (SELECT c1, c2, ROW_NUMBER() OVER(PARTITION BY 3) as rn
3856
+
FROM aggregate_test_100
3857
+
LIMIT 5)
3858
+
GROUP BY rn
3859
+
ORDER BY rn;
3860
+
----
3861
+
c 2 1
3862
+
d 5 2
3863
+
b 1 3
3864
+
a 1 4
3865
+
b 5 5
3866
+
3867
+
statement error DataFusion error: Error during planning: Projection references non-aggregate values: Expression aggregate_test_100.c1 could not be resolved from available columns: rn
3868
+
SELECT *
3869
+
FROM (SELECT c1, c2, ROW_NUMBER() OVER(PARTITION BY c1) as rn
0 commit comments