Commit d5251c1
authored
fix: VARIANT follow-ups for SchemaTransform etc (delta-io#1106)
## What changes are proposed in this pull request?
Follow-up from VARIANT work in delta-io#1015. chiefly: (1) modify
`transform_variant` to take/return structtypes, and default to recursing
through children, and (2) track a couple follow ups in TODOs.
the actual bug that must be fixed is that when a VARIANT went in to
`transform_variant`, it came back out as a regular STRUCT if
transformed, since DataType::from on a struct is just a struct (note
that if not transformed, we return the original data_type which is still
variant)
original comment kept below for posterity
### Original exploration in earlier commits
Originally prompted as follow-up from delta-io#1015, this serves as an
exploration of introducing a new `VariantType` struct (similar to
`MapType`/`ArrayType`/etc.) which just wraps `StructType`.
The original question pertaining to `SchemaTransform` was basically: can
we implement `transform_variant` to take+return a `StructType` instead
of `DataType`? This loses the information that says the thing is a
variant and not a normal struct. This prompted the exploration of how we
actually want to represent Variant in our schemas. In general we need a
way of distinguishing variants from plain structs
I think we have two options: we either rely on `DataType` which
communicates `DataType::Variant(struct_type)` OR we introduce a new
`StructType` much like MapType/ArrayType/etc.
This PR serves as exploration of the former - though i'm realizing if we
_do_ take `DataType` as the thing that 'tags' a struct as variant then
it's probably also okay? And would just have the schema transform still
retain taking/returning DataType? (or perhaps could consume a StructType
but just always return a DataType)
I remember @nicklan had even more/better thoughts around this - please
comment and we can discuss :)
## How was this change tested?
Existing UT1 parent 9325ec6 commit d5251c1
4 files changed
Lines changed: 22 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
874 | 874 | | |
875 | 875 | | |
876 | 876 | | |
877 | | - | |
878 | | - | |
879 | | - | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
880 | 881 | | |
881 | 882 | | |
882 | 883 | | |
| |||
896 | 897 | | |
897 | 898 | | |
898 | 899 | | |
899 | | - | |
900 | | - | |
901 | | - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
902 | 903 | | |
903 | 904 | | |
904 | 905 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
158 | 166 | | |
159 | 167 | | |
160 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
| |||
357 | 361 | | |
358 | 362 | | |
359 | 363 | | |
360 | | - | |
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
| |||
375 | 378 | | |
376 | 379 | | |
377 | 380 | | |
378 | | - | |
379 | 381 | | |
380 | 382 | | |
381 | 383 | | |
| |||
0 commit comments