Skip to content

Decouple builtin aggregate function first_value from optimize rule replace_distinct_aggregate #10703

Closed
@jayzhan211

Description

@jayzhan211

Is your feature request related to a problem or challenge?

If we move the built-in function out of the optimizer, it is more easy to extend/adapt the optimizer rule to other UDAFs. For example, change the first_value (datafusion builtin) to first_value (UDAF) or my_function (UDAF) in replace_distinct_aggregate.

Discussion from #10648 (comment)

Describe the solution you'd like

  1. Move the replace_distinct_aggregate to functions-aggregate as part of the builtin optimize rule, and register the rule to optimizer rules
  2. Enable FunctionRegistry in the optimizer rule, we always get the function with the name "first_value" here, if they have first_value UDAF, they can take advantage of this rule by replacing the first_value to their version.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

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