@@ -386,3 +386,53 @@ drop table m3;
386
386
387
387
statement ok
388
388
drop table m3_source;
389
+
390
+
391
+ ## Test that filtering on dictionary columns coerces the filter value to the dictionary type
392
+ statement ok
393
+ create table test as values
394
+ ('row1', arrow_cast('1', 'Dictionary(Int32, Utf8)')),
395
+ ('row2', arrow_cast('2', 'Dictionary(Int32, Utf8)')),
396
+ ('row3', arrow_cast('3', 'Dictionary(Int32, Utf8)'))
397
+ ;
398
+
399
+ # query using an string '1' which must be coerced into a dictionary string
400
+ query T?
401
+ SELECT * from test where column2 = '1';
402
+ ----
403
+ row1 1
404
+
405
+ # filter should not have a cast on column2
406
+ query TT
407
+ explain SELECT * from test where column2 = '1';
408
+ ----
409
+ logical_plan
410
+ 01)Filter: test.column2 = Dictionary(Int32, Utf8("1"))
411
+ 02)--TableScan: test projection=[column1, column2]
412
+ physical_plan
413
+ 01)CoalesceBatchesExec: target_batch_size=8192
414
+ 02)--FilterExec: column2@1 = 1
415
+ 03)----MemoryExec: partitions=1, partition_sizes=[1]
416
+
417
+
418
+ # Now query using an integer which must be coerced into a dictionary string
419
+ query T?
420
+ SELECT * from test where column2 = 1;
421
+ ----
422
+ row1 1
423
+
424
+ # filter should not have a cast on column2
425
+ query TT
426
+ explain SELECT * from test where column2 = 1;
427
+ ----
428
+ logical_plan
429
+ 01)Filter: test.column2 = Dictionary(Int32, Utf8("1"))
430
+ 02)--TableScan: test projection=[column1, column2]
431
+ physical_plan
432
+ 01)CoalesceBatchesExec: target_batch_size=8192
433
+ 02)--FilterExec: column2@1 = 1
434
+ 03)----MemoryExec: partitions=1, partition_sizes=[1]
435
+
436
+
437
+ statement ok
438
+ drop table test;
0 commit comments