Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping optimizer rule due to create_name not supporting wildcard #4681

Closed
andre-cc-natzka opened this issue Dec 20, 2022 · 0 comments · Fixed by #4682
Closed

Skipping optimizer rule due to create_name not supporting wildcard #4681

andre-cc-natzka opened this issue Dec 20, 2022 · 0 comments · Fixed by #4682
Labels
bug Something isn't working

Comments

@andre-cc-natzka
Copy link
Contributor

Describe the bug
We ran into a problem when running queries that do not explicitly mention some dimension(s). We found out that, while handling these dimensions, an Expr::Wildcard is created. This in itself is not a problem, but may become one when the type_coercion and unwrap_cast_in_comparison optimization rules call the display_name method on this expression, which is not allowed because the create_name method called inside display_name does not support Expr::Wildcard.

To go a bit more into detail, the optimize_internal methods from type_coercion and unwrap_cast_in_comparison call the rewrite_preserving_name function from datafusion/optimizer/src/utils.rs, which just rewrites an expression while keeping its name unchanged. It calls name_for_alias, which gets the name of an expression by calling display_name, which in turn gives rise to the warnings.

This only prevents the type_coercion and unwrap_cast_in_comparison optimization rules from being applied to the schema dimensions we are not considering, so should not be a problem, but gives rise to some annoying warnings during query execution.

To Reproduce
This behavior can be recovered by running queries where one or several cube dimensions are not explicitly mentioned, giving rise to Expr::Wildcards. When trying to apply the optimization rules type_coercion and unwrap_cast_in_comparison , the following output is obtained:

WARN datafusion_optimizer::optimizer: Skipping optimizer rule 'type_coercion' due to unexpected error: Internal error: Create name does not support wildcard.
WARN datafusion_optimizer::optimizer: Skipping optimizer rule 'unwrap_cast_in_comparison' due to unexpected error: Internal error: Create name does not support wildcard.

Expected behavior
We expect the query to run with no warnings at all, and let the optimization rules be applied to all the sub-plans (even if it is not required for query execution). To do that, we must find a way to allow to rewrite an expression of type Expr::Wildcard without calling display_name(), since this will give rise to the above mentioned error message originating from create_name(). A simple workaround could be, in the name_for_alias function, to consider separately the case in which the expression is of type Expr::Wildcard, and make sure it is given a reasonable name (e.g. "*") instead of calling display_name(). Another solution could be to introduce the change directly in create_name(), by modifying the action in case Expr::Wildcard is found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant