Skip to content

Update comments on OptimizerRule about function name matching#20346

Merged
alamb merged 4 commits intoapache:mainfrom
alamb:alamb/documentation
Feb 24, 2026
Merged

Update comments on OptimizerRule about function name matching#20346
alamb merged 4 commits intoapache:mainfrom
alamb:alamb/documentation

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Feb 13, 2026

Which issue does this PR close?

Rationale for this change

I gave feedback to @devanshu0987 https://github.com/apache/datafusion/pull/20180/changes#r2800720037 that it was not a good idea to check for function names in optimizer rules, but then I realized that the rationale for this is not written down anywhere.

What changes are included in this PR?

Document why checking for function names in optimizer rules is not good and offer alternatives

Are these changes tested?

By CI

Are there any user-facing changes?

Just docs, no functional changes

@alamb alamb added the documentation Improvements or additions to documentation label Feb 13, 2026
@github-actions github-actions bot added optimizer Optimizer rules functions Changes to functions implementation and removed documentation Improvements or additions to documentation labels Feb 13, 2026
@alamb alamb force-pushed the alamb/documentation branch from 2137f99 to 6071a18 Compare February 13, 2026 19:59
@github-actions github-actions bot removed the functions Changes to functions implementation label Feb 13, 2026
@alamb alamb added the documentation Improvements or additions to documentation label Feb 13, 2026
@alamb alamb changed the title Alamb/documentation Update comments on OptimizerRule about function name matching Feb 13, 2026
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Feb 13, 2026
Copy link
Contributor Author

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @neilconway -- I did the changes in 6759858

@alamb alamb marked this pull request as ready for review February 13, 2026 20:27
Copy link
Contributor

@2010YOUY01 2010YOUY01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the doc. I believe this is a pretty important detail to know!

/// ## Matching on functions
///
/// The rule should avoid function-specific transformations, and instead use
/// methods on [`ScalarUDFImpl`] and [`AggregateUDFImpl`]. Specifically, the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember there are still several cases that rely on function name checking, where it is not possible to implement the optimization using methods on ScalarUDFImpl.

We have a tracking issue, should we link it here? #18643

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great call -- added in 05f8ca1

github-merge-queue bot pushed a commit that referenced this pull request Feb 23, 2026
## Which issue does this PR close?

- Similarly to #20346

## Rationale for this change

As part of PR reviews, it seems like it is not obvious to some
contributors that there is a non trivial cost to adding new optimizer
rules. Let's add that knowledge into the codebase as comments, so it may
be less of a surprise

## What changes are included in this PR?

Add comments
## Are these changes tested?
N/A
## Are there any user-facing changes?
No this is entirely internal comments oly

---------

Co-authored-by: Adrian Garcia Badaracco <[email protected]>
@alamb alamb added this pull request to the merge queue Feb 24, 2026
Merged via the queue into apache:main with commit fdd36d0 Feb 24, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants