-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature Add Monotonic Definition #59
Changes from 9 commits
a2919b6
14109e6
b3d75ba
549502e
623e0c5
6a9d24e
53ee3de
97d8951
cc33031
41d9430
e988dcf
906245e
475fe2d
57e000e
ca57f46
6cf9644
072e6ef
7d62cb0
491aabe
71996fb
1920771
8d542ec
dc445a1
ecc5694
7f0c71b
d051731
f8063e8
3a991e6
a4917d4
66b4da2
972c56f
4b946b3
481b5b4
29af731
1f02953
79dd942
247d5fe
16bdac4
1875336
8464f0a
50ac43d
2a8b885
62000b4
1da5252
d18a1d3
5897438
3f48520
a93b4de
2510e34
60c0fb8
707f673
99f907b
ba7b94f
2152b7f
0d367dd
51a23cf
b79efc0
7822613
5e9b2db
7efa2f3
0edc3d9
54d62d6
29e9a1c
c077ef5
07ee09a
11435de
53728b3
1146811
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,7 +389,7 @@ pub trait AggregateUDFImpl: Debug + Send + Sync { | |
|
||
/// Whether the aggregate function is nullable. | ||
/// | ||
/// Nullable means that that the function could return `null` for any inputs. | ||
/// Nullable means that the function could return `null` for any inputs. | ||
/// For example, aggregate functions like `COUNT` always return a non null value | ||
/// but others like `MIN` will return `NULL` if there is nullable input. | ||
/// Note that if the function is declared as *not* nullable, make sure the [`AggregateUDFImpl::default_value`] is `non-null` | ||
|
@@ -635,6 +635,18 @@ pub trait AggregateUDFImpl: Debug + Send + Sync { | |
fn documentation(&self) -> Option<&Documentation> { | ||
None | ||
} | ||
|
||
/// Indicates whether the aggregation function is monotonic as a set function. A set | ||
/// function is monotonically increasing if its value increases as its argument grows | ||
/// (as a set). Formally, `f` is a monotonically increasing set function if `f(S) >= f(T)` | ||
/// whenever `S` is a superset of `T`. | ||
/// | ||
/// Returns None if the function is not monotonic. | ||
/// If the function is monotonically decreasing returns Some(false) e.g. Min | ||
/// If the function is monotonically increasing returns Some(true) e.g. Max | ||
fn is_monotonic(&self) -> Option<bool> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we will need to accept a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add it first so we don't have to break API again in the future |
||
None | ||
} | ||
} | ||
|
||
impl PartialEq for dyn AggregateUDFImpl { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess
avg
is monotonic for integer but not for float?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it's not monotonic for unsigned integers, for example:
1st data 100 => Avg 100
2nd data 2 => (102/2) Avg 51 (decreased)
3rd data 3 => (105/3) Avg 35 (decreased)
4th data 1003 => (1108/4) Avg 277 (increased)
To be monotonic, it needs to be always increasing/decreasing