You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "ngli-me (via GitHub)" <gi...@apache.org> on 2024/09/10 18:37:35 UTC
[PR] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
ngli-me opened a new pull request, #12421:
URL: https://github.com/apache/datafusion/pull/12421
## 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 #8932.
## 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.
-->
Smaller PR for changing the Datafusion side subfields/structs relating to the `WindowFunction` expression type. There are still a few Arrow types that need PartialOrd implementations, looking for some direction on whether those should be added, or if the comparison for those fields can be ignored.
## 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.
-->
BuiltInWindowFunction -> Derives PartialOrd
AggregateUDFImpl -> Manual implementation of PartialOrd based on `name` + `signature` fields
AggergateUDF -> Derives PartialOrd from impl (Added tests for this ordering as well)
WindowUDFImpl -> Manual implementation of PartialOrd based on `name` + `signature` fields
WindowUDF -> Derives PartialOrd from impl (Added tests for this ordering as well)
TypeSignature -> Manual implementation of PartialOrd, with some tests.
## 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)?
-->
Yes, but not extensively.
## 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.
-->
Some of the subtypes will have PartialOrd applicable.
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#discussion_r1754831765
##########
datafusion/expr-common/src/signature.rs:
##########
@@ -127,7 +129,62 @@ pub enum TypeSignature {
Numeric(usize),
}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+// manual implementation of `PartialOrd`
Review Comment:
I think we could automatically derive `PartialOrd` for these enums rather than implement them manually.
using `derive` I think would be easier to maintain over the long term (aka it is easier to add new variants to the enum without having ti update the partial ord implemetnation)
I tried this locally and it seems to work:
```diff
andrewlamb@Andrews-MacBook-Pro-2:~/Software/datafusion$ git diff
diff --git a/datafusion/expr-common/src/signature.rs b/datafusion/expr-common/src/signature.rs
index 2043757a4..3f0f61f2f 100644
--- a/datafusion/expr-common/src/signature.rs
+++ b/datafusion/expr-common/src/signature.rs
@@ -84,7 +84,7 @@ pub enum Volatility {
/// DataType::Timestamp(TimeUnit::Nanosecond, Some(TIMEZONE_WILDCARD.into())),
/// ]);
/// ```
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd)]
pub enum TypeSignature {
/// One or more arguments of an common type out of a list of valid types.
///
@@ -127,7 +127,7 @@ pub enum TypeSignature {
Numeric(usize),
}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd)]
pub enum ArrayFunctionSignature {
/// Specialized Signature for ArrayAppend and similar functions
/// The first argument should be List/LargeList/FixedSizedList, and the second argument should be non-list or list.
```
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "ngli-me (via GitHub)" <gi...@apache.org>.
ngli-me commented on PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#issuecomment-2346710336
Made some adjustments to fix that clippy issue and fmt.
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #12421:
URL: https://github.com/apache/datafusion/pull/12421
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#issuecomment-2345949455
(I think the description of this PR might need to be udpated)
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "ngli-me (via GitHub)" <gi...@apache.org>.
ngli-me commented on code in PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#discussion_r1755878706
##########
datafusion/expr-common/src/signature.rs:
##########
@@ -127,7 +129,62 @@ pub enum TypeSignature {
Numeric(usize),
}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+// manual implementation of `PartialOrd`
Review Comment:
Ah, for some reason I thought that derives wouldn't work with an enum with differing types, but I see it does work with the tests. Added an additional sanity assertion just to check, and removed the manual implementation for TypeSignature, thanks!
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "ngli-me (via GitHub)" <gi...@apache.org>.
ngli-me commented on code in PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#discussion_r1755878706
##########
datafusion/expr-common/src/signature.rs:
##########
@@ -127,7 +129,62 @@ pub enum TypeSignature {
Numeric(usize),
}
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+// manual implementation of `PartialOrd`
Review Comment:
Ah, for some reason I thought that derives wouldn't work with an enum with differing types, but I see it does work with the tests. Added an additional sanity one just to check, and removed the manual implementation for TypeSignature, thanks!
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#issuecomment-2347086911
🚀
THanks again @ngli-me
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#issuecomment-2400081358
> If there is some reason that we can't avoid it, can we compare with the name only?
I think one place it is used is to normalize the order of expressions (maybe for CSE or simplification 🤔 )
Comparing on name is probably fine too I would think
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#issuecomment-2346075963
Also, there appears to be a clippy failure
--
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] Add PartialOrd for the DF subfields/structs for the WindowFunction expr [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #12421:
URL: https://github.com/apache/datafusion/pull/12421#issuecomment-3166678656
> Can we not implement PartialOrd for function? I don't think it make sense to have ordering concept for the function.
I agree.
What's worse, the current implementation is incorrect with respect to `PartialOrd` and `PartialEq` contract
- https://github.com/apache/datafusion/issues/17064
--
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