@@ -127,9 +127,21 @@ TEST_F(StringAggregatesTest, nonFixedWidthAggregate) {
127127 testWindowFunction (input, " max(c2)" , kOverClauses );
128128}
129129
130- class KPreceedingFollowingTest : public WindowTestBase {};
130+ class KPrecedingFollowingTest : public WindowTestBase {
131+ public:
132+ const std::vector<std::string> kRangeFrames = {
133+ " range between unbounded preceding and 1 following" ,
134+ " range between unbounded preceding and 2 following" ,
135+ " range between unbounded preceding and 3 following" ,
136+ " range between 1 preceding and unbounded following" ,
137+ " range between 2 preceding and unbounded following" ,
138+ " range between 3 preceding and unbounded following" ,
139+ " range between 1 preceding and 3 following" ,
140+ " range between 3 preceding and 1 following" ,
141+ " range between 2 preceding and 2 following" };
142+ };
131143
132- TEST_F (KPreceedingFollowingTest , rangeFrames1) {
144+ TEST_F (KPrecedingFollowingTest , rangeFrames1) {
133145 auto vectors = makeRowVector ({
134146 makeFlatVector<int64_t >({1 , 1 , 2147483650 , 3 , 2 , 2147483650 }),
135147 makeFlatVector<std::string>({" 1" , " 1" , " 1" , " 2" , " 1" , " 2" }),
@@ -147,7 +159,7 @@ TEST_F(KPreceedingFollowingTest, rangeFrames1) {
147159 testWindowFunction ({vectors}, " count(c0)" , {overClause}, kRangeFrames2 );
148160}
149161
150- TEST_F (KPreceedingFollowingTest , rangeFrames2) {
162+ TEST_F (KPrecedingFollowingTest , rangeFrames2) {
151163 const std::vector<RowVectorPtr> vectors = {
152164 makeRowVector (
153165 {makeFlatVector<int64_t >({5 , 6 , 8 , 9 , 10 , 2 , 8 , 9 , 3 }),
@@ -164,36 +176,42 @@ TEST_F(KPreceedingFollowingTest, rangeFrames2) {
164176 makeRowVector (
165177 {makeFlatVector<int64_t >({5 , 5 , 4 , 6 , 3 , 2 }),
166178 makeFlatVector<std::string>({" 1" , " 2" , " 2" , " 2" , " 1" , " 2" })}),
167- // Uses int32 for sort column.
179+ // Uses int32 type for sort column.
168180 makeRowVector (
169181 {makeFlatVector<int32_t >({5 , 5 , 4 , 6 , 3 , 2 }),
170182 makeFlatVector<std::string>({" 1" , " 2" , " 2" , " 2" , " 1" , " 2" })}),
171183 };
172-
173184 const std::string overClause = " partition by c1 order by c0" ;
174- const std::vector<std::string> kRangeFrames = {
175- " range between unbounded preceding and 1 following" ,
176- " range between unbounded preceding and 2 following" ,
177- " range between unbounded preceding and 3 following" ,
178- " range between 1 preceding and unbounded following" ,
179- " range between 2 preceding and unbounded following" ,
180- " range between 3 preceding and unbounded following" ,
181- " range between 1 preceding and 3 following" ,
182- " range between 3 preceding and 1 following" ,
183- " range between 2 preceding and 2 following" };
184185 for (int i = 0 ; i < vectors.size (); i++) {
185186 testWindowFunction ({vectors[i]}, " avg(c0)" , {overClause}, kRangeFrames );
186187 testWindowFunction ({vectors[i]}, " sum(c0)" , {overClause}, kRangeFrames );
187188 testWindowFunction ({vectors[i]}, " count(c0)" , {overClause}, kRangeFrames );
188189 }
189190}
190191
191- TEST_F (KPreceedingFollowingTest, rowsFrames) {
192+ TEST_F (KPrecedingFollowingTest, rangeFrames3) {
193+ const std::vector<RowVectorPtr> vectors = {
194+ // Uses date type for sort column.
195+ makeRowVector (
196+ {makeFlatVector<Date>(
197+ {Date (6 ), Date (1 ), Date (5 ), Date (0 ), Date (7 ), Date (1 )}),
198+ makeFlatVector<std::string>({" 1" , " 2" , " 2" , " 2" , " 1" , " 2" })}),
199+ makeRowVector (
200+ {makeFlatVector<Date>(
201+ {Date (5 ), Date (5 ), Date (4 ), Date (6 ), Date (3 ), Date (2 )}),
202+ makeFlatVector<std::string>({" 1" , " 2" , " 2" , " 2" , " 1" , " 2" })}),
203+ };
204+ const std::string overClause = " partition by c1 order by c0" ;
205+ for (int i = 0 ; i < vectors.size (); i++) {
206+ testWindowFunction ({vectors[i]}, " count(c0)" , {overClause}, kRangeFrames );
207+ }
208+ }
209+
210+ TEST_F (KPrecedingFollowingTest, rowsFrames) {
192211 auto vectors = makeRowVector ({
193212 makeFlatVector<int64_t >({1 , 1 , 2147483650 , 3 , 2 , 2147483650 }),
194213 makeFlatVector<std::string>({" 1" , " 1" , " 1" , " 2" , " 1" , " 2" }),
195214 });
196-
197215 const std::string overClause = " partition by c1 order by c0" ;
198216 const std::vector<std::string> kRangeFrames = {
199217 " rows between current row and 2147483647 following" ,
0 commit comments