-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 function volatility to Signature #1071
Conversation
…nature type which has volatility calssification
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.
Great work @pjmore !
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.
Beautiful. Ready to go imo.
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.
BuiltinScalarFunction::Upper => Volatility::Immutable, | ||
BuiltinScalarFunction::RegexpMatch => Volatility::Immutable, | ||
|
||
//Stable builtin functions |
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.
👍
python/tests/test_df.py
Outdated
@@ -81,7 +81,7 @@ def test_limit(df): | |||
|
|||
def test_udf(df): | |||
# is_null is a pa function over arrays | |||
udf = f.udf(lambda x: x.is_null(), [pa.int64()], pa.bool_()) | |||
udf = f.udf(lambda x: x.is_null(), [pa.int64()], pa.bool_(), f.Volatility.immutable()) |
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 believe this line is causing the python code formatter to fail
You can fix it by running a command such as the following
cd datafusion
black --line-length 79 python
Thanks again @pjmore ! |
Which issue does this PR close?
Closes #1069.
Rationale for this change
Make volatility a first class concept for functions.
What changes are included in this PR?
Renamed the Signature enum to TypeSignature and added Signature struct which currently has 2 fields, type_signature and volatility. I initially tried adding another field containing the volatility to the original Signature enum but this felt clunky and while it could potential allow for conditionally stable\immutable functions with the OneOf variant that seemed like a fairly niche optimization.
Are there any user-facing changes?
Yes Signature was renamed and volatility has been added. There are breaking changes to the public API from this, could someone add the
api-break
label? I don't have permission to add labels.