@@ -169,6 +169,101 @@ logical_plan
16916901)Filter: floor(test_data.float_val) = Float64(5.5)
17017002)--TableScan: test_data projection=[id, float_val, int_val, decimal_val]
171171
172+ ##########
173+ ## Other Comparison Operators
174+ ##
175+ ## The preimage framework automatically handles all comparison operators:
176+ ## floor(x) <> N -> x < N OR x >= N+1
177+ ## floor(x) > N -> x >= N+1
178+ ## floor(x) < N -> x < N
179+ ## floor(x) >= N -> x >= N
180+ ## floor(x) <= N -> x < N+1
181+ ##########
182+
183+ # Data correctness tests for other operators
184+
185+ # Not equals: floor(x) <> 5 matches values outside [5.0, 6.0)
186+ query I rowsort
187+ SELECT id FROM test_data WHERE floor(float_val) <> arrow_cast(5, 'Float64');
188+ ----
189+ 3
190+ 4
191+ 5
192+
193+ # Greater than: floor(x) > 5 matches values in [6.0, inf)
194+ query I rowsort
195+ SELECT id FROM test_data WHERE floor(float_val) > arrow_cast(5, 'Float64');
196+ ----
197+ 3
198+ 4
199+ 5
200+
201+ # Less than: floor(x) < 6 matches values in (-inf, 6.0)
202+ query I rowsort
203+ SELECT id FROM test_data WHERE floor(float_val) < arrow_cast(6, 'Float64');
204+ ----
205+ 1
206+ 2
207+
208+ # Greater than or equal: floor(x) >= 5 matches values in [5.0, inf)
209+ query I rowsort
210+ SELECT id FROM test_data WHERE floor(float_val) >= arrow_cast(5, 'Float64');
211+ ----
212+ 1
213+ 2
214+ 3
215+ 4
216+ 5
217+
218+ # Less than or equal: floor(x) <= 5 matches values in (-inf, 6.0)
219+ query I rowsort
220+ SELECT id FROM test_data WHERE floor(float_val) <= arrow_cast(5, 'Float64');
221+ ----
222+ 1
223+ 2
224+
225+ # EXPLAIN tests showing optimized transformations
226+
227+ # Not equals: floor(x) <> 5 -> x < 5 OR x >= 6
228+ query TT
229+ EXPLAIN SELECT * FROM test_data WHERE floor(float_val) <> arrow_cast(5, 'Float64');
230+ ----
231+ logical_plan
232+ 01)Filter: test_data.float_val < Float64(5) OR test_data.float_val >= Float64(6)
233+ 02)--TableScan: test_data projection=[id, float_val, int_val, decimal_val]
234+
235+ # Greater than: floor(x) > 5 -> x >= 6
236+ query TT
237+ EXPLAIN SELECT * FROM test_data WHERE floor(float_val) > arrow_cast(5, 'Float64');
238+ ----
239+ logical_plan
240+ 01)Filter: test_data.float_val >= Float64(6)
241+ 02)--TableScan: test_data projection=[id, float_val, int_val, decimal_val]
242+
243+ # Less than: floor(x) < 6 -> x < 6
244+ query TT
245+ EXPLAIN SELECT * FROM test_data WHERE floor(float_val) < arrow_cast(6, 'Float64');
246+ ----
247+ logical_plan
248+ 01)Filter: test_data.float_val < Float64(6)
249+ 02)--TableScan: test_data projection=[id, float_val, int_val, decimal_val]
250+
251+ # Greater than or equal: floor(x) >= 5 -> x >= 5
252+ query TT
253+ EXPLAIN SELECT * FROM test_data WHERE floor(float_val) >= arrow_cast(5, 'Float64');
254+ ----
255+ logical_plan
256+ 01)Filter: test_data.float_val >= Float64(5)
257+ 02)--TableScan: test_data projection=[id, float_val, int_val, decimal_val]
258+
259+ # Less than or equal: floor(x) <= 5 -> x < 6
260+ query TT
261+ EXPLAIN SELECT * FROM test_data WHERE floor(float_val) <= arrow_cast(5, 'Float64');
262+ ----
263+ logical_plan
264+ 01)Filter: test_data.float_val < Float64(6)
265+ 02)--TableScan: test_data projection=[id, float_val, int_val, decimal_val]
266+
172267##########
173268## Cleanup
174269##########
0 commit comments