Column logical (not physical) type and allow_schema_mismatch#606
Column logical (not physical) type and allow_schema_mismatch#606
Conversation
karan6181
left a comment
There was a problem hiding this comment.
Looks good overall. Can you please add unit test for the new changes?
| 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.
nit: why the word maybe?
There was a problem hiding this comment.
because the check may happen or it may not
There was a problem hiding this comment.
Yeah, but it depends on whether the flag allow_schema_mismatch is true or not. So, maybe, check all schemas match?
| class Str(Encoding): | ||
| """Store str.""" | ||
|
|
||
| logical_type = LogicalStr |
There was a problem hiding this comment.
Wondering, where is this getting used?
There was a problem hiding this comment.
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)
| 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.
Are mixed logical types of the same kind (like int32 + int64) not allowed?
There was a problem hiding this comment.
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?
snarayan21
left a comment
There was a problem hiding this comment.
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.