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

Minor: Move get_equal_orderings into BuiltInWindowFunctionExpr, remove BuiltInWindowFunctionExpr::as_any #6619

Merged
merged 4 commits into from
Jun 13, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jun 9, 2023

Which issue does this PR close?

This is related to #5781

Rationale for this change

I would like to ensure that user defined window functions have the same expressive power as built in window functions.

In order to achieve this goal, all the important information about a window function is provided by a trait (rather than by other code special casing based on the type).

What changes are included in this PR?

  1. Move get_equal_orderings into BuiltInWindowFunctionExpr
  2. Remove BuiltInWindowFunctionExpr::as_any (which is how I found the special case for RowNumber)

Are these changes tested?

Covered by existing tests

Are there any user-facing changes?

No this only changes internal APIs

Note that my proposal in #6617 for user defined window functions is to make BuiltInWindowFunctionExpr public. However, even if we choose another option, I think this still PR makes the code more explicit and easier to find functionality related to window functions so I think it is still a good change

@github-actions github-actions bot added core Core DataFusion crate physical-expr Physical Expressions labels Jun 9, 2023
.get_built_in_func_expr()
.as_any()
.is::<RowNumber>()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point of the PR is to remove this special case for RowNumber (which I did by hoisting it into the trait)

@@ -61,6 +58,24 @@ impl BuiltInWindowFunctionExpr for RowNumber {
&self.name
}

fn add_equal_orderings(&self, builder: &mut OrderingEquivalenceBuilder) {
// Only the built-in `RowNumber` window function introduces a new
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can replace comment
// Only the built-in RowNumber window function introduces a new with
// The built-in RowNumber window function introduces a new. Since method implements it (and special handling is not done outside), we do not need stress this is the only window function with this property.

Copy link
Contributor Author

@alamb alamb Jun 12, 2023

Choose a reason for hiding this comment

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

👍 done in commit ad16502

Copy link
Contributor

@mustafasrepo mustafasrepo left a comment

Choose a reason for hiding this comment

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

Thanks @alamb. Other than minor comments, this PR is LGTM!.

With these changes, if the user defined window function introduces ordering, user can add this information and utilize this information in subsequent stages.

By the way regarding the as_any() as fas as I can remember it is not introduces by us. I am not familiar with its purpose. However, even though we no longer have special handling outside and no use-case for it in datafusion code base. I can imagine it may be useful for others. I wonder what others think about it.

@alamb
Copy link
Contributor Author

alamb commented Jun 12, 2023

By the way regarding the as_any() as fas as I can remember it is not introduces by us. I am not familiar with its purpose. However, even though we no longer have special handling outside and no use-case for it in datafusion code base. I can imagine it may be useful for others. I wonder what others think about it.

@jimexist (who I think added the first version of window functions and perhaps the trait), @andygrove, @viirya or @Dandandan do you have any thoughts about keeping / removing the as_any, or leaving it in?

Given the question, I think the safe thing will be to change this PR to put back the as_any and we can then discuss that change separately. I'll plan to restore as_any in this PR if I don't hear any other comments

@alamb
Copy link
Contributor Author

alamb commented Jun 12, 2023

I have reverted the changes to as_any in ef89135

@alamb alamb merged commit 071a2a6 into apache:main Jun 13, 2023
@alamb alamb deleted the alamb/remove_as_any branch June 14, 2023 11:08
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants