-
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
Add isOrderable and isComparable for Type #6770
Conversation
✅ Deploy Preview for meta-velox canceled.
|
2041291
to
3d968d5
Compare
@mbasmanova Hi Masha, I've updated the PR with the logical type solution and added related tests, could you please help to take a look? Thanks a lot. |
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.
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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 think there's a small bug above.
|
||
rowType = ROW({INTEGER(), mapType}); | ||
EXPECT_FALSE(rowType->isOrderable()); | ||
EXPECT_FALSE(rowType->isComparable()); |
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.
the tests here don't catch the bug I pointed out above. Maybe re-design the test so that isOrderable != isComparable?
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.
@pedroerp Yes, the test case in line 883 is wrong (it was intended to test isOrderable != isComparable
), I've updated it, thanks.
auto mapType = MAP(INTEGER(), REAL());
...
rowType = ROW({INTEGER(), mapType});
EXPECT_FALSE(rowType->isOrderable());
- EXPECT_FALSE(rowType->isComparable());
+ EXPECT_TRUE(rowType->isComparable());
velox/type/Type.h
Outdated
@@ -455,6 +455,10 @@ class Type : public Tree<const TypePtr>, public velox::ISerializable { | |||
|
|||
virtual bool isPrimitiveType() const = 0; | |||
|
|||
virtual bool isOrderable() const = 0; |
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.
here would be the right place for a comment explaining what exactly these two methods should return, semantically.
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.
9894314
to
8b4af07
Compare
@mbasmanova @pedroerp @bikramSingh91 I've resolved all the comments added comments for the two APIs, and updated the test cases to guard the difference between the two APIs. Could you please help to take a look? Thanks. |
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 Thank you for iterating. Looks great % one comment.
velox/type/Type.h
Outdated
@@ -455,6 +455,16 @@ class Type : public Tree<const TypePtr>, public velox::ISerializable { | |||
|
|||
virtual bool isPrimitiveType() const = 0; | |||
|
|||
/// Return true if the type is scalar type or unknown type. Return false if |
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.
This is a virtual method and therefore it cannot say what its implementations will return. Instead in need to explain what the return value means. How about,
Returns true if equality relationship is defined for the values of this type, i.e. a == b is defined and returns true, false or null.
For example, scalar types are usually comparable and complex types are comparable if their nested types are.
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, updated.
velox/type/Type.h
Outdated
/// if all its children types are comparable. | ||
virtual bool isComparable() const = 0; | ||
|
||
/// Return true if the type is scalar type or unknown type. Return false if |
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.
ditto
Returns true if less than relationship is defined for the values of this type, i.e. a <= b returns true or false.
For example, scalar types are usually orderable, arrays and structs are orderable if their nested types are, while map types are not orderable.
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.
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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.
@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 b661e8c. |
…n signature (#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 #6770 to do the check during type binding in `SignatureBinder.tryBind`. Part of #6718 Pull Request resolved: #6906 Reviewed By: xiaoxmeng Differential Revision: D49951511 Pulled By: mbasmanova fbshipit-source-id: 17ee5fd75b25a7df636279d07e99773105349220
Summary: In Presto, input to min/max/array_sort is restricted to orderable types. For example, MAP type is not orderable. Velox currently allows MAP inputs. This PR extends the Velox Type class to add `isOrderable()` and `isComparable()` methods. Part of facebookincubator#6718 and facebookincubator#6712 Pull Request resolved: facebookincubator#6770 Reviewed By: Yuhta Differential Revision: D49693596 Pulled By: mbasmanova fbshipit-source-id: 1386904dde45691368e759831b4bf24287b0de5d
…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
In Presto, input to min/max/array_sort is restricted to orderable types. For example, MAP type is not orderable. Velox currently allows MAP inputs.
This PR extends the Velox Type class to add
isOrderable()
andisComparable()
methods.Part of #6718 and #6712