-
Notifications
You must be signed in to change notification settings - Fork 166
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
docs: clarify nullability information source for empty literals #602
Conversation
ACTION NEEDED Substrait follows the Conventional Commits The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
proto/substrait/algebra.proto
Outdated
// * Type null | ||
// * Type.List empty_list | ||
// * Type.Map empty_map | ||
// which should declare their nullability directly instead. |
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 need to verify but the text format appears to set both for empty lists and just the type for empty maps (based on its test cases taken from Isthmus).
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.
@EpsilonPrime where you able to verify this?
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 shouldn't matter going forward, I will make sure that the text format follows this guideline by adding some tests.
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.
For empty lists the following behavior is present for the text format:
{}_list<string> -> nothing nullable
{}_list<string?> -> literal is nullable, list is not nullable
{}_list?<string> -> list is nullable, literal is not
{}_list?<string?> -> both are nullable
It seems like this nullability covers the nullability of the list even if it's empty. Even if it's empty is it legal to have a nullable version of it?
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 the empty_map tests in substrait-io/substrait-cpp#97.
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 text format is definitely using this nullability over the one in the type. It's the same behavior it uses for non-empty lists and maps.
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 for removing the ambiguity
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 wording is ok. I have a suggestion for something slightly different if we want.
I want to double check something before merging this, will look at it this week. |
81dfb73
to
08ad96f
Compare
Weston's suggestion clarified this for me. I think this should be good as is with his changes incorporated. |
Will check this on Thursday. |
// Whether the literal_type above should be treated as a nullable type. | ||
// Applies to all members of the literal_type oneof EXCEPT: | ||
// * Type null (must be nullable by definition) | ||
// * Type.List empty_list (use Type.List::nullability) |
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.
If the Type.List::nullability is the nullability of the type inside the list then I don't think this applies.
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.
substrait/proto/substrait/type.proto
Lines 186 to 190 in 1a51b3d
message List { | |
Type type = 1; | |
uint32 type_variation_reference = 2; | |
Nullability nullability = 3; | |
} |
I believe that Type.List::nullability
is the nullability of the list itself, and Type.List::type::nullability
is the nullability of the internal type.
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.
That matches what I believe. But for empty lists and empty maps why is that any different than populated lists and maps?
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.
Empty lists and empty maps have two spots for list nullability (so we need to pick one to be authoritative):
// List nullability (authoritative)
Literal::empty_list::list::nullability
// Also list nullability (redundant)
Literal::nullability
Populated lists and maps have one spot for list nullability and one spot for item nullability:
// Applies to the item
Literal::list::values...nullability
// Applies to the list (only option, thus authoritative)
Literal::nullability
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.
Okay, I see it now. An alternative would be to change the type of of empty_list and empty_map to Type but that doesn't work simply for maps (which would need two nullability values for its key and type).
Looking at the
oneof literal_type
block I noticed that theempty_list
variant andempty_map
variant reuse aType
message, much like thenull
variant.Like
Type
,Type.List
andType.Map
also declare their nullability directly. To avoid ambiguity, I updated the docs to specify that the nullability of these literals should come from the inner message here, and not from thenullable
field of theLiteral
message.