@@ -901,3 +901,234 @@ cases:
901901 200, 1, 1
902902 300, 0, 0
903903 400, 2, 2
904+
905+ # ======================================================================
906+ # WINDOW without ORDER BY
907+ # ======================================================================
908+ - id : 24
909+ desc : ROWS WINDOW WITHOUT ORDER BY
910+ mode : batch-unsupport
911+ inputs :
912+ - name : t1
913+ columns :
914+ - id int
915+ - gp int
916+ - ts timestamp
917+ indexs :
918+ - idx:gp:ts
919+ data : |
920+ 1, 100, 20000
921+ 2, 100, 10000
922+ 3, 400, 20000
923+ 4, 400, 10000
924+ 5, 400, 15000
925+ 6, 400, 40000
926+ sql : |
927+ select id, count(ts) over w as agg
928+ from t1
929+ window w as (
930+ partition by gp
931+ rows between 2 open preceding and current row
932+ )
933+ request_plan : |
934+ PROJECT(type=Aggregation)
935+ REQUEST_UNION(partition_keys=(), orders=, rows=(, 2 OPEN PRECEDING, 0 CURRENT), index_keys=(gp))
936+ DATA_PROVIDER(request=t1)
937+ DATA_PROVIDER(type=Partition, table=t1, index=idx)
938+ cluster_request_plan : |
939+ SIMPLE_PROJECT(sources=(id, agg))
940+ REQUEST_JOIN(type=kJoinTypeConcat)
941+ SIMPLE_PROJECT(sources=(id))
942+ DATA_PROVIDER(request=t1)
943+ PROJECT(type=Aggregation)
944+ REQUEST_UNION(partition_keys=(), orders=, rows=(, 2 OPEN PRECEDING, 0 CURRENT), index_keys=(gp))
945+ DATA_PROVIDER(request=t1)
946+ DATA_PROVIDER(type=Partition, table=t1, index=idx)
947+ expect :
948+ columns : ["id int", "agg int64"]
949+ order : id
950+ data : |
951+ 1, 1
952+ 2, 2
953+ 3, 1
954+ 4, 2
955+ 5, 2
956+ 6, 2
957+ - id : 25
958+ desc : RANGE WINDOW WITHOUT ORDER BY
959+ mode : batch-unsupport
960+ inputs :
961+ - name : t1
962+ columns :
963+ - id int
964+ - gp int
965+ - ts timestamp
966+ indexs :
967+ - idx:gp:ts
968+ data : |
969+ 1, 100, 20000
970+ 2, 100, 10000
971+ 3, 400, 20000
972+ 4, 400, 10
973+ 5, 400, 15000
974+ sql : |
975+ select id, count(ts) over w as agg
976+ from t1
977+ window w as (
978+ partition by gp
979+ rows_range between unbounded preceding and current row
980+ )
981+ request_plan : |
982+ PROJECT(type=Aggregation)
983+ REQUEST_UNION(partition_keys=(), orders=, range=(, 0 PRECEDING UNBOUND, 0 CURRENT), index_keys=(gp))
984+ DATA_PROVIDER(request=t1)
985+ DATA_PROVIDER(type=Partition, table=t1, index=idx)
986+ cluster_request_plan : |
987+ SIMPLE_PROJECT(sources=(id, agg))
988+ REQUEST_JOIN(type=kJoinTypeConcat)
989+ SIMPLE_PROJECT(sources=(id))
990+ DATA_PROVIDER(request=t1)
991+ PROJECT(type=Aggregation)
992+ REQUEST_UNION(partition_keys=(), orders=, range=(, 0 PRECEDING UNBOUND, 0 CURRENT), index_keys=(gp))
993+ DATA_PROVIDER(request=t1)
994+ DATA_PROVIDER(type=Partition, table=t1, index=idx)
995+ expect :
996+ columns : ["id int", "agg int64"]
997+ order : id
998+ data : |
999+ 1, 1
1000+ 2, 2
1001+ 3, 1
1002+ 4, 2
1003+ 5, 3
1004+ - id : 26
1005+ desc : RANGE-type WINDOW WITHOUT ORDER BY + WINDOW attributes
1006+ mode : batch-unsupport
1007+ inputs :
1008+ - name : t1
1009+ columns :
1010+ - id int
1011+ - gp int
1012+ - ts timestamp
1013+ indexs :
1014+ - idx:gp:ts
1015+ data : |
1016+ 1, 100, 20000
1017+ 2, 100, 10000
1018+ 3, 400, 20000
1019+ 4, 400, 10000
1020+ 5, 400, 15000
1021+ - name : t2
1022+ columns :
1023+ - id int
1024+ - gp int
1025+ - ts timestamp
1026+ indexs :
1027+ - idx:gp:ts
1028+ data : |
1029+ 1, 100, 20000
1030+ 2, 100, 10000
1031+ 3, 400, 20000
1032+ 4, 400, 10000
1033+ 5, 400, 15000
1034+ sql : |
1035+ select id,
1036+ count(ts) over w1 as agg1,
1037+ count(ts) over w2 as agg2,
1038+ count(ts) over w3 as agg3,
1039+ count(ts) over w4 as agg4,
1040+ count(ts) over w5 as agg5,
1041+ count(ts) over w6 as agg6,
1042+ count(ts) over w7 as agg7,
1043+ from t1
1044+ window w1 as (
1045+ PARTITION by gp
1046+ ROWS_RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1047+ w2 as (partition by gp
1048+ ROWS_RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW),
1049+ w3 as (PARTITION BY gp
1050+ ROWS_RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW MAXSIZE 1),
1051+ w4 as (
1052+ UNION (select * from t2)
1053+ PARTITION BY gp
1054+ ROWS_RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW),
1055+ w5 as (
1056+ UNION (select * from t2)
1057+ PARTITION BY gp
1058+ ROWS_RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW EXCLUDE CURRENT_ROW),
1059+ w6 as (
1060+ UNION (select * from t2)
1061+ PARTITION BY gp
1062+ ROWS_RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW MAXSIZE 2 INSTANCE_NOT_IN_WINDOW EXCLUDE CURRENT_ROW),
1063+ w7 as (
1064+ UNION (select * from t2)
1065+ PARTITION BY gp
1066+ ROWS_RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW)
1067+ expect :
1068+ columns : ["id int", "agg1 int64", "agg2 int64", "agg3 int64", "agg4 int64", "agg5 int64", "agg6 int64", "agg7 int64"]
1069+ order : id
1070+ data : |
1071+ 1, 1, 0, 1, 3, 2, 2, 2
1072+ 2, 2, 1, 1, 3, 2, 2, 3
1073+ 3, 1, 0, 1, 4, 3, 2, 3
1074+ 4, 2, 1, 1, 4, 3, 2, 4
1075+ 5, 3, 2, 1, 4, 3, 2, 5
1076+ - id : 27
1077+ desc : ROWS-type WINDOW WITHOUT ORDER BY + WINDOW attributes
1078+ mode : batch-unsupport
1079+ inputs :
1080+ - name : t1
1081+ columns :
1082+ - id int
1083+ - gp int
1084+ - ts timestamp
1085+ indexs :
1086+ - idx:gp:ts
1087+ data : |
1088+ 1, 100, 20000
1089+ 2, 100, 10000
1090+ 3, 400, 20000
1091+ 4, 400, 10000
1092+ 5, 400, 15000
1093+ - name : t2
1094+ columns :
1095+ - id int
1096+ - gp int
1097+ - ts timestamp
1098+ indexs :
1099+ - idx:gp:ts
1100+ data : |
1101+ 1, 100, 20000
1102+ 2, 100, 10000
1103+ 3, 400, 20000
1104+ 4, 400, 10000
1105+ 5, 400, 15000
1106+ sql : |
1107+ select id,
1108+ count(ts) over w1 as agg1,
1109+ count(ts) over w2 as agg2,
1110+ count(ts) over w3 as agg3,
1111+ count(ts) over w4 as agg4,
1112+ from t1
1113+ window w1 as (
1114+ PARTITION by gp
1115+ ROWS BETWEEN 2 PRECEDING AND CURRENT ROW),
1116+ w2 as (partition by gp
1117+ ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW),
1118+ w3 as (
1119+ UNION (select * from t2)
1120+ PARTITION BY gp
1121+ ROWS BETWEEN 2 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW),
1122+ w4 as (
1123+ UNION (select * from t2)
1124+ PARTITION BY gp
1125+ ROWS BETWEEN 3 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW EXCLUDE CURRENT_ROW)
1126+ expect :
1127+ columns : ["id int", "agg1 int64", "agg2 int64", "agg3 int64", "agg4 int64"]
1128+ order : id
1129+ data : |
1130+ 1, 1, 0, 3, 2
1131+ 2, 2, 1, 3, 2
1132+ 3, 1, 0, 3, 3
1133+ 4, 2, 1, 3, 3
1134+ 5, 3, 2, 3, 3
0 commit comments