Sevenannn opened a new pull request, #12610:
URL: https://github.com/apache/datafusion/pull/12610
## Which issue does this PR close?
No relevant issue
## Rationale for this change
Datafusion enforces an eager cast of value to dictionary value in the
logical plan where a comparison with dictionary value is presented. For
example, in the following plan
```SQL
Filter: person_mood.mood_status = CAST(Utf8("happy") AS Dictionary(Int8,
Utf8))
```
However, when using unparser to convert the plan back to sql, where the sql
will be sent to various query engine (PostgreSQL, MySQL, etc.) the cast is not
needed for the value, in the example above the value `happy`, since the raw
value can be directly used in SQL engines without casting to an engine specific
dictionary type. Therefore, the plan can simply be rewritten into
```SQL
where person_mood.mood_status = 'happy'
```
## What changes are included in this PR?
* Directly pass `inner_expr` instead of `cast inner_expr as dictionary` in
the `Expr::Cast` case when the `inner_expr` is a `Value` representing constant
and the plan is `cast to dictionary`
* Add a test for the change
## Are these changes tested?
Yes
## Are there any user-facing changes?
No
--
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]