jayzhan211 commented on code in PR #10323:
URL: https://github.com/apache/datafusion/pull/10323#discussion_r1585678884
##########
datafusion/sqllogictest/test_files/dictionary.slt:
##########
@@ -386,3 +386,38 @@ drop table m3;
statement ok
drop table m3_source;
+
+
+## Test that filtering on dictionary columns coerces the filter value to the
dictionary type
+statement ok
+create table test as values
+ ('row1', arrow_cast('1', 'Dictionary(Int32, Utf8)')),
+ ('row2', arrow_cast('2', 'Dictionary(Int32, Utf8)')),
+ ('row3', arrow_cast('3', 'Dictionary(Int32, Utf8)'))
+;
+
+# query using an string '1' which must be coerced into a dictionary string
+query T?
+SELECT * from test where column2 = '1';
+----
+row1 1
+
+# filter should not have a cast on column2
+query TT
+explain SELECT * from test where column2 = '1';
+----
+logical_plan
+01)Filter: test.column2 = Dictionary(Int32, Utf8("1"))
+02)--TableScan: test projection=[column1, column2]
+physical_plan
+01)CoalesceBatchesExec: target_batch_size=8192
+02)--FilterExec: column2@1 = 1
+03)----MemoryExec: partitions=1, partition_sizes=[1]
+
+
+# Now query using an integer which must be coerced into a dictionary string
+query T?
+SELECT * from test where column2 = 1;
Review Comment:
`explain` query for this is helpful too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]