-
Notifications
You must be signed in to change notification settings - Fork 149
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
Column logical (not physical) type and allow_schema_mismatch #606
base: delta
Are you sure you want to change the base?
Conversation
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 good overall. Can you please add unit test for the new changes?
@@ -479,6 +480,22 @@ def __init__( | |||
self.stream_per_shard = np.array(stream_per_shard, np.int64) | |||
self.num_shards = len(self.shards) | |||
|
|||
# Maybe check all schemas match. |
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.
nit: why the word maybe
?
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.
because the check may happen or it may not
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.
Yeah, but it depends on whether the flag allow_schema_mismatch
is true or not. So, maybe, check all schemas match
?
@@ -36,6 +41,8 @@ def _validate(data: Any, expected_type: Any) -> bool: | |||
class Str(Encoding): | |||
"""Store str.""" | |||
|
|||
logical_type = LogicalStr |
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.
Wondering, where is this getting used?
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.
streaming.format.mds.encoding.MDSEncoding.logical_type
(start here)
->
streaming.format.base.type.Type
(then go to the logical type class)
->
streaming.format.base.type.Type.get_signature
(it has a stringify single column method)
->
streaming.format.base.shard.base.Shard.get_logical_type_signature
(which is used by shard to stringify all columns for equality comparison)
->
streaming.dataset.StreamingDataset.__init__
(which is needed for allow_schema_mismatch
impl)
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.
LGTM
if not allow_schema_mismatch: | ||
sigs = [shard.get_logical_type_signature() for shard in self.shards] | ||
sig2count = Counter(sigs) | ||
if len(sig2count) != 1: |
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.
Are mixed logical types of the same kind (like int32 + int64) not allowed?
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.
Not allowed at this time for MVP. Maybe in the future, we would go with the wider type for all shards? But that would be kind of magical and might interact with custom getitem work?
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.
Everything looks good to me! Could you add unit testing for these changes, including one that does fail the schema matching check?
This PR was split out of a larger Parquet streaming PR, to follow.
allow_schema_mismatch
-- checks all shards to verify that their schema (column name and type signatures) match. This functionality is an important safety check for Parquet streaming relating to accidentally including Parquet files and other user error.