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

Add window func related logic plan to proto ability. #4485

Merged
merged 3 commits into from
Dec 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions datafusion/proto/src/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,20 @@ pub fn parse_expr(
.ok_or_else(|| Error::unknown("BuiltInWindowFunction", *i))?
.into();

let args = match parse_optional_expr(&expr.expr, registry)? {
None => {
vec![]
}
Some(x) => {
vec![x]
}
};

Ok(Expr::WindowFunction {
fun: datafusion_expr::window_function::WindowFunction::BuiltInWindowFunction(
built_in_function,
),
args: vec![parse_required_expr(&expr.expr, registry, "expr")?],
Copy link
Member Author

Choose a reason for hiding this comment

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

Unlike WindowFunction with AggrFunction like min(col). max(col). sum(col) it must have required_exp

Built-in WindowFunction like ROW_NUMBER() . RANK(). DENSE() have to have this value

args,
partition_by,
order_by,
window_frame,
Expand Down Expand Up @@ -1234,16 +1243,14 @@ impl TryFrom<protobuf::WindowFrameBound> for WindowFrameBound {
})?;
match bound_type {
protobuf::WindowFrameBoundType::CurrentRow => Ok(Self::CurrentRow),
protobuf::WindowFrameBoundType::Preceding => {
// FIXME implement bound value parsing
// https://github.com/apache/arrow-datafusion/issues/361
Ok(Self::Preceding(ScalarValue::UInt64(Some(1))))
}
protobuf::WindowFrameBoundType::Following => {
// FIXME implement bound value parsing
// https://github.com/apache/arrow-datafusion/issues/361
Ok(Self::Following(ScalarValue::UInt64(Some(1))))
}
protobuf::WindowFrameBoundType::Preceding => match bound.bound_value {
Some(x) => Ok(Self::Preceding(ScalarValue::try_from(&x)?)),
None => Ok(Self::Preceding(ScalarValue::UInt64(None))),
},
protobuf::WindowFrameBoundType::Following => match bound.bound_value {
Some(x) => Ok(Self::Following(ScalarValue::try_from(&x)?)),
None => Ok(Self::Following(ScalarValue::UInt64(None))),
},
}
}
}
Expand Down