Skip to content

support data type coerced and decimal in INLIST expr #2755

@liukun4515

Description

@liukun4515

related issue:

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
(This section helps Arrow developers understand the context and why for this feature, in addition to the what)

When I apply the in list filter to the below table

❯ \d food
+---------------+--------------+------------+-------------+-----------------+-------------+
| table_catalog | table_schema | table_name | column_name | data_type       | is_nullable |
+---------------+--------------+------------+-------------+-----------------+-------------+
| datafusion    | public       | food       | a           | Decimal(10, 5)  | NO          |
| datafusion    | public       | food       | b           | Decimal(20, 15) | NO          |
| datafusion    | public       | food       | c           | Boolean         | NO          |
+---------------+--------------+------------+-------------+-----------------+-------------+

❯  select * from food where a in (1);
ArrowError(ExternalError(NotImplemented("InList does not support datatype Decimal(10, 5).")))

explain the query:

❯ explain select * from food where a in (1);
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan_type     | plan                                                                                                                                                                         |
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| logical_plan  | Projection: #food.a, #food.b, #food.c                                                                                                                                        |
|               |   Filter: #food.a IN ([Int64(1)])                                                                                                                                            |
|               |     TableScan: food projection=Some([a, b, c]), partial_filters=[#food.a IN ([Int64(1)])]                                                                                    |
| physical_plan | ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c]                                                                                                                          |
|               |   CoalesceBatchesExec: target_batch_size=4096                                                                                                                                |
|               |     FilterExec: a@0 IN ([CastExpr { expr: Literal { value: Int64(1) }, cast_type: Decimal(10, 5), cast_options: CastOptions { safe: false } }])                              |
|               |       RepartitionExec: partitioning=RoundRobinBatch(16)                                                                                                                      |
|               |         CsvExec: files=[/Users/kliu3/Documents/github/arrow-datafusion/datafusion-cli/target/debug/aggregate_simple.csv], has_header=false, limit=None, projection=[a, b, c] |
|               |                                                                                                                                                                              |
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set. Query took 0.007 seconds.

We need convert the data type of expr and list to the common data type.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions