Sevenannn opened a new pull request, #13427:
URL: https://github.com/apache/datafusion/pull/13427

   ## Which issue does this PR close?
   
   N/A
   
   ## Rationale for this change
   
   Datafusion enforces an eager cast of value to `Binary` / `BinaryView` value 
in the logical plan where a comparison with binary value is presented. For 
example, in the following plan
   
   `Filter: value = CAST(Utf8("binary_value") AS Binary`
   However, when using unparser to convert the plan back to sql, where the sql 
will be sent to various query engine (e.g. DuckDB). the cast is not needed for 
the value, in the example above the value "binary_value", 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 where value = 
'binary_value'
   
   ## What changes are included in this PR?
   
   - Add function `cast_to_sql`, which directly pass inner_expr instead of cast 
inner_expr when casting to binary / binaryview / dictionary in the Expr::Cast, 
and keep the original casting logic in all other cases.
   - 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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to