Skip to content

Expose TypeCoercionRewriter::new  #13375

@niebayes

Description

@niebayes

Is your feature request related to a problem or challenge?

Our database uses sqlparser to parse a custom SQL statement, and we skip the logical plan to directly construct an execution plan with DataFusion. This SQL statement includes a WHERE clause, so we need to construct a FilterExec. During the process of building FilterExec, we found that the create_physical_expr method from the datafusion-physical-expr module doesn’t perform type coercion, but instead assumes all expressions have already undergone type coercion.

To implement type coercion, we reviewed the DataFusion source code and found that from higher-level APIs to lower-level ones, there are several approaches that support type coercion for expressions:

  • Using SessionContext::create_physical_expr
  • Using ExprSimplifier::coerce
  • Using TreeNodeRewriter::rewrite based on TypeCoercionRewriter
  • Using TreeNode::transform

In our case, we only want to perform type coercion on expressions, so TypeCoercionRewriter seems to be the best fit. However, we’re unable to create a TypeCoercionRewriter instance because its new method isn’t public.

We would like DataFusion to expose TypeCoercionRewriter::new. If there is another, simpler method to achieve this, please let us know. Thank you.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

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