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

implement lead and lag with 2nd and 3rd argument #554

Closed
jimexist opened this issue Jun 13, 2021 · 5 comments · Fixed by #687
Closed

implement lead and lag with 2nd and 3rd argument #554

jimexist opened this issue Jun 13, 2021 · 5 comments · Fixed by #687
Labels
enhancement New feature or request

Comments

@jimexist
Copy link
Member

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
(This section helps Arrow developers understand the context and why for this feature, in addition to the what)

follow up with #553 , we can additionally support 2nd and 3rd argument

Describe the solution you'd like
A clear and concise description of what you want to happen.

Similar to postgresql function definitions

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@jimexist jimexist added the enhancement New feature or request label Jun 13, 2021
@jgoday
Copy link
Contributor

jgoday commented Jul 4, 2021

Hi @jimexist, Could I take a look at this ?

As I understand it:

  • a BuiltInWindowFunctionExpr and a PartitionEvaluator has to be implemented under physical_plan/expressions, lag and lead functions should be created with a name, an expression, and the offset/default_value optional arguments.

  • return_type_for_built_in and signature_for_built_in should be changed for Lag/Lead (physical_plan/window_functions)

  • signature has to be a Signature::OneOf( (expr -> result), (expr, offset) -> result, (expr, offset, default_value) -> result )

I'm probably missing some details, but would this approach be valid ?

@jimexist
Copy link
Member Author

jimexist commented Jul 4, 2021

Hi @jimexist, Could I take a look at this ?

As I understand it:

  • a BuiltInWindowFunctionExpr and a PartitionEvaluator has to be implemented under physical_plan/expressions, lag and lead functions should be created with a name, an expression, and the offset/default_value optional arguments.

  • return_type_for_built_in and signature_for_built_in should be changed for Lag/Lead (physical_plan/window_functions)

  • signature has to be a Signature::OneOf( (expr -> result), (expr, offset) -> result, (expr, offset, default_value) -> result )

I'm probably missing some details, but would this approach be valid ?

Go ahead and thanks!

the way is see it currently there is no easy way to express heterogeneity in arg types so i would stick with any and check inside the actual execution phase.

@jimexist
Copy link
Member Author

jimexist commented Jul 4, 2021

Hi @jimexist, Could I take a look at this ?

As I understand it:

  • a BuiltInWindowFunctionExpr and a PartitionEvaluator has to be implemented under physical_plan/expressions, lag and lead functions should be created with a name, an expression, and the offset/default_value optional arguments.

  • return_type_for_built_in and signature_for_built_in should be changed for Lag/Lead (physical_plan/window_functions)

  • signature has to be a Signature::OneOf( (expr -> result), (expr, offset) -> result, (expr, offset, default_value) -> result )

I'm probably missing some details, but would this approach be valid ?

And you don't need to creat a different expr or physical expr you can just modify the current one to take additional arguments

@jgoday
Copy link
Contributor

jgoday commented Jul 4, 2021

Oh, sorry, I was looking to an old fork, I didn't realize that lag and lead were already implemented in the main branch :)
All clear then, I will try to implement the offset and default_value arguments only

jgoday added a commit to jgoday/arrow-datafusion that referenced this issue Jul 5, 2021
…guments

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Tue Jul 6 00:11:25 2021 +0200
#
# On branch lead_lag_optional_arguments
# Changes to be committed:
#	modified:   src/physical_plan/expressions/lead_lag.rs
#	modified:   src/physical_plan/type_coercion.rs
#	modified:   src/physical_plan/window_functions.rs
#	modified:   src/physical_plan/windows.rs
#
@jgoday
Copy link
Contributor

jgoday commented Jul 5, 2021

I have created a PR (#687) and commented some doubts about the implementation in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants