Skip to content

Conversation

@ozankabak
Copy link
Contributor

@ozankabak ozankabak commented Jul 25, 2024

Which issue does this PR close?

Closes #.

Rationale for this change

Reducing API clutter for checking/verifying/regularizing window frames.

What changes are included in this PR?

Apart from the said API simplification, fixes the window fuzz tests to make it clear when streaming execution is not possible. Also removes some unwrap calls from window related code.

Are these changes tested?

Yes

Are there any user-facing changes?

A very minor change at the API level: The regularize function becomes a method of WindowFrame

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions core Core DataFusion crate labels Jul 25, 2024
@ozankabak ozankabak requested review from alamb and mustafasrepo July 25, 2024 11:17
.order_by(order_by)
.window_frame(window_frame)
.build()
.unwrap())
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a nice improvement too

|| frame.end_bound.is_unbounded())
{
plan_err!("RANGE requires exactly one ORDER BY column")?
/// Returns whether the window frame can accept multiple ORDER BY expressons.
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this is much nicer

Copy link
Contributor

@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.

Thank you @ozankabak -- this looks like a nice improvement to me

Comment on lines 263 to 267
order_by.push(Expr::Sort(Sort::new(
Box::new(Expr::Literal(ScalarValue::UInt64(Some(1)))),
true,
false,
)));
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW you can write this more succinctly with the expr API like this I think

Suggested change
order_by.push(Expr::Sort(Sort::new(
Box::new(Expr::Literal(ScalarValue::UInt64(Some(1)))),
true,
false,
)));
order_by.push(lit(1u64).sort(true, false));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed much nicer, thank you -- added

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.

LGTM!.

@ozankabak ozankabak merged commit 7db4213 into apache:main Jul 25, 2024
@ozankabak
Copy link
Contributor Author

Did a Rust version update just land? CI checks were passing in-branch, but we have clippy and doc failures on CI post merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate logical-expr Logical plan and expressions sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants