-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow restricting arguments as orderable or comparable in the function signature #6906
Conversation
✅ Deploy Preview for meta-velox canceled.
|
53be93d
to
905275c
Compare
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.
@duanmeng Nice change. Looks good % some minor comments.
velox/expression/FunctionSignature.h
Outdated
@@ -58,6 +60,27 @@ class SignatureVariable { | |||
return knownTypesOnly_; | |||
} | |||
|
|||
void setKnownTypesOnly(bool knownTypesOnly) { |
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.
Let's keep this class immutable and remove these setters.
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.
Got it, fixed.
velox/expression/FunctionSignature.h
Outdated
addVariable( | ||
variables_, | ||
SignatureVariable(name, "", ParameterType::kTypeParameter, true)); | ||
if (variables_.find(name) == variables_.end()) { |
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.
Looks like this logic is to allow calling both orderableTypeVariable and knownTypeVariable in the same signature. Do we need this? How about we don't allow if and if necessary add knownOrderableTypeVariable later?
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.
It seems we do not need it for now. It is better to make them mutually exclusive and keep SignatureVarible
immutable. I will update this PR according to these principles.
: name_{std::move(name)}, | ||
constraint_(constraint.has_value() ? std::move(constraint.value()) : ""), | ||
type_{type}, | ||
knownTypesOnly_(knownTypesOnly) { | ||
knownTypesOnly_(knownTypesOnly), |
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.
Can we add a check that the new properties apply only when isTypeParameter() true?
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.
Added.
@@ -378,6 +378,53 @@ TEST(SignatureBinderTest, knownOnly) { | |||
} | |||
} | |||
|
|||
TEST(SignatureBinderTest, orderableComparable) { | |||
auto signature = exec::FunctionSignatureBuilder() | |||
.orderableTypeVariable("T") |
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.
orderable implies comparable, hence, no point specifying both
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.
Removed
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.
Thanks.
@@ -79,6 +93,8 @@ class SignatureVariable { | |||
// This property only applies to type variables and indicates if the type | |||
// can bind to unknown or not. | |||
bool knownTypesOnly_ = false; | |||
bool orderableTypesOnly_ = false; |
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.
Perhaps, update the comment above:
// The following properties apply only to type variables and indicate whether the type can bind only to known, orderable or comparable types.
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.
Updated
velox/expression/FunctionSignature.h
Outdated
FunctionSignatureBuilder& knownTypeVariable(const std::string& name); | ||
|
||
/// Orderable implies comparable, this method would enable | ||
/// comaprableTypesOnly_ too. |
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.
typo: comaprableTypesOnly_ -> comparableTypesOnly_
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.
Fixed
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@mbasmanova merged this pull request in 96f8ef5. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
Summary: PR #6906 added support to restricting arguments as orderable. This PR changes ArgumentTypeFuzzer to respect this constraint. Part of #6718 Pull Request resolved: #6950 Reviewed By: Yuhta Differential Revision: D50212902 Pulled By: mbasmanova fbshipit-source-id: 318b5e443baba7b6800539fafcf34946e6f0e91d
…n signature (facebookincubator#6906) Summary: In Presto, input to min/max is restricted to orderable types. For example, MAP type is not orderable. Velox currently allows MAP inputs. This PR adds two APIs in `FunctionSignatureBuilder`: `orderableTypeVariable` and `comparableTypeVariable`. Use type's `orderable` and `comparable` flag added in facebookincubator#6770 to do the check during type binding in `SignatureBinder.tryBind`. Part of facebookincubator#6718 Pull Request resolved: facebookincubator#6906 Reviewed By: xiaoxmeng Differential Revision: D49951511 Pulled By: mbasmanova fbshipit-source-id: 17ee5fd75b25a7df636279d07e99773105349220
…#6950) Summary: PR facebookincubator#6906 added support to restricting arguments as orderable. This PR changes ArgumentTypeFuzzer to respect this constraint. Part of facebookincubator#6718 Pull Request resolved: facebookincubator#6950 Reviewed By: Yuhta Differential Revision: D50212902 Pulled By: mbasmanova fbshipit-source-id: 318b5e443baba7b6800539fafcf34946e6f0e91d
In Presto, input to min/max is restricted to orderable types.
For example, MAP type is not orderable. Velox currently allows MAP inputs.
This PR adds two APIs in
FunctionSignatureBuilder
:orderableTypeVariable
and
comparableTypeVariable
. Use type'sorderable
andcomparable
flagadded in #6770 to do the check
during type binding in
SignatureBinder.tryBind
.Part of #6718