You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "dqkqd (via GitHub)" <gi...@apache.org> on 2025/10/12 09:44:00 UTC
[PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
dqkqd opened a new pull request, #18024:
URL: https://github.com/apache/datafusion/pull/18024
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #17417.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #18024:
URL: https://github.com/apache/datafusion/pull/18024#issuecomment-3413405307
Thanks @dqkqd
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #18024:
URL: https://github.com/apache/datafusion/pull/18024#discussion_r2427753952
##########
datafusion/proto/proto/datafusion.proto:
##########
@@ -622,6 +626,12 @@ message WindowFrameBound {
datafusion_common.ScalarValue bound_value = 2;
}
+enum NullTreatment {
+ NULL_TREATMENT_UNSPECIFIED = 0;
Review Comment:
I guess we never did it before because we don't try to maintain version compatibility:
https://github.com/apache/datafusion/blob/b27fedcd3224f305e29ef4e67de232842808f650/datafusion/proto/src/lib.rs#L46-L50
##########
datafusion/proto/src/logical_plan/from_proto.rs:
##########
@@ -571,14 +596,27 @@ pub fn parse_expr(
.udaf(&pb.fun_name)
.or_else(|_| codec.try_decode_udaf(&pb.fun_name, &[]))?,
};
+ let null_treatment = match pb.null_treatment {
+ Some(null_treatment) => {
+ let null_treatment = protobuf::NullTreatment::try_from(null_treatment)
+ .map_err(|_| {
+ proto_error(format!(
+ "Received an AggregateUdfExprNode message with unknown NullTreatment {}",
+ null_treatment
+ ))
+ })?;
+ Some(null_treatment.try_into()?)
+ }
+ None => None,
+ };
Ok(Expr::AggregateFunction(expr::AggregateFunction::new_udf(
agg_fn,
parse_exprs(&pb.args, registry, codec)?,
pb.distinct,
parse_optional_expr(pb.filter.as_deref(), registry, codec)?.map(Box::new),
parse_sorts(&pb.order_by, registry, codec)?,
- None,
+ null_treatment,
Review Comment:
Nice catch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #18024:
URL: https://github.com/apache/datafusion/pull/18024
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #18024:
URL: https://github.com/apache/datafusion/pull/18024#discussion_r2427385050
##########
datafusion/proto/src/logical_plan/from_proto.rs:
##########
@@ -571,14 +596,27 @@ pub fn parse_expr(
.udaf(&pb.fun_name)
.or_else(|_| codec.try_decode_udaf(&pb.fun_name, &[]))?,
};
+ let null_treatment = match pb.null_treatment {
+ Some(null_treatment) => {
+ let null_treatment = protobuf::NullTreatment::try_from(null_treatment)
+ .map_err(|_| {
+ proto_error(format!(
+ "Received an AggregateUdfExprNode message with unknown NullTreatment {}",
+ null_treatment
+ ))
+ })?;
+ Some(null_treatment.try_into()?)
+ }
+ None => None,
+ };
Ok(Expr::AggregateFunction(expr::AggregateFunction::new_udf(
agg_fn,
parse_exprs(&pb.args, registry, codec)?,
pb.distinct,
parse_optional_expr(pb.filter.as_deref(), registry, codec)?.map(Box::new),
parse_sorts(&pb.order_by, registry, codec)?,
- None,
+ null_treatment,
Review Comment:
Noticed that we don't have `null_treatment` for aggregate udf.
So I handle this as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on PR #18024:
URL: https://github.com/apache/datafusion/pull/18024#issuecomment-3399261938
@geoffreyclaude
In the issue description, there is an updating doc criteria but I couldn't find where they are. Could you please tell me where to update the docs?
> Docs updated to state proto supports these window-function features.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #18024:
URL: https://github.com/apache/datafusion/pull/18024#discussion_r2427383773
##########
datafusion/proto/proto/datafusion.proto:
##########
@@ -622,6 +626,12 @@ message WindowFrameBound {
datafusion_common.ScalarValue bound_value = 2;
}
+enum NullTreatment {
+ NULL_TREATMENT_UNSPECIFIED = 0;
Review Comment:
As described in the issue, there should be a `UNSPECIFIED` field.
This is also noted here:
https://protobuf.dev/best-practices/dos-donts/#unspecified-enum
But I don't see we are doing it for other enums.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #18024:
URL: https://github.com/apache/datafusion/pull/18024#discussion_r2427392489
##########
datafusion/proto/proto/datafusion.proto:
##########
@@ -622,6 +626,12 @@ message WindowFrameBound {
datafusion_common.ScalarValue bound_value = 2;
}
+enum NullTreatment {
+ NULL_TREATMENT_UNSPECIFIED = 0;
Review Comment:
e.g:
https://github.com/apache/datafusion/blob/b27fedcd3224f305e29ef4e67de232842808f650/datafusion/proto/proto/datafusion.proto#L1314-L1317
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: support `null_treatment`, `distinct`, and `filter` for window functions in proto [datafusion]
Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on PR #18024:
URL: https://github.com/apache/datafusion/pull/18024#issuecomment-3403404173
Thank you @Jefffrey
I didn't see that we clarified we don't maintain compatibility.
I also prefer not to use `UNSPECIFIED`, to keep it consistent with existing enums.
I’ll make the change and revert it if there are other opinions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org