@@ -97,14 +97,70 @@ public void testReverseWithComplexPipeline() throws IOException {
9797 }
9898
9999 @ Test
100- public void testReverseWithMultipleSorts () throws IOException {
101- // Use the existing BANK data but with a simpler, more predictable query
100+ public void testReverseWithDescendingSort () throws IOException {
101+ // Test reverse with descending sort (- age)
102102 JSONObject result =
103103 executeQuery (
104104 String .format (
105- "source=%s | sort account_number | fields account_number | reverse | head 3 " ,
105+ "source=%s | sort - account_number | fields account_number | reverse" ,
106106 TEST_INDEX_BANK ));
107107 verifySchema (result , schema ("account_number" , "bigint" ));
108- verifyDataRowsInOrder (result , rows (32 ), rows (25 ), rows (20 ));
108+ verifyDataRowsInOrder (
109+ result , rows (1 ), rows (6 ), rows (13 ), rows (18 ), rows (20 ), rows (25 ), rows (32 ));
110+ }
111+
112+ @ Test
113+ public void testReverseWithMixedSortDirections () throws IOException {
114+ // Test reverse with mixed sort directions (- age, + firstname)
115+ JSONObject result =
116+ executeQuery (
117+ String .format (
118+ "source=%s | sort - account_number, + firstname | fields account_number, firstname"
119+ + " | reverse" ,
120+ TEST_INDEX_BANK ));
121+ verifySchema (result , schema ("account_number" , "bigint" ), schema ("firstname" , "string" ));
122+ verifyDataRowsInOrder (
123+ result ,
124+ rows (1 , "Amber JOHnny" ),
125+ rows (6 , "Hattie" ),
126+ rows (13 , "Nanette" ),
127+ rows (18 , "Dale" ),
128+ rows (20 , "Elinor" ),
129+ rows (25 , "Virginia" ),
130+ rows (32 , "Dillard" ));
131+ }
132+
133+ @ Test
134+ public void testDoubleReverseWithDescendingSort () throws IOException {
135+ // Test double reverse with descending sort (- age)
136+ JSONObject result =
137+ executeQuery (
138+ String .format (
139+ "source=%s | sort - account_number | fields account_number | reverse | reverse" ,
140+ TEST_INDEX_BANK ));
141+ verifySchema (result , schema ("account_number" , "bigint" ));
142+ verifyDataRowsInOrder (
143+ result , rows (32 ), rows (25 ), rows (20 ), rows (18 ), rows (13 ), rows (6 ), rows (1 ));
144+ }
145+
146+ @ Test
147+ public void testDoubleReverseWithMixedSortDirections () throws IOException {
148+ // Test double reverse with mixed sort directions (- age, + firstname)
149+ JSONObject result =
150+ executeQuery (
151+ String .format (
152+ "source=%s | sort - account_number, + firstname | fields account_number, firstname"
153+ + " | reverse | reverse" ,
154+ TEST_INDEX_BANK ));
155+ verifySchema (result , schema ("account_number" , "bigint" ), schema ("firstname" , "string" ));
156+ verifyDataRowsInOrder (
157+ result ,
158+ rows (32 , "Dillard" ),
159+ rows (25 , "Virginia" ),
160+ rows (20 , "Elinor" ),
161+ rows (18 , "Dale" ),
162+ rows (13 , "Nanette" ),
163+ rows (6 , "Hattie" ),
164+ rows (1 , "Amber JOHnny" ));
109165 }
110166}
0 commit comments