Initial spec for lists and structs#113
Conversation
| * `date`: calendar dates, written as ISO 8601 strings (`YYYY-MM-DD`, e.g. `2024-01-31`). | ||
| * `datetime`: date-times, written as ISO 8601 strings. Without a `time_zone` they carry an offset (e.g. `2024-01-31T09:30:00Z`); with a `time_zone` they're written zoneless and interpreted in that zone (see [Time zones](#time-zones)). | ||
| * `enum`: a column with repeated values from a known set. The allowed values are listed in the `values` property. | ||
| * `list(element_type)`: an ordered sequence of zero or more elements of the given type (see [List element types](#list-element-types)). |
There was a problem hiding this comment.
Are list and struct the right names?
There was a problem hiding this comment.
list definitely. struct is as good as any imo
|
|
||
| * `primary_key`: the set of columns with the `primary_key` constraint uniquely identifies each row. Implies `required` and `unique`. | ||
| * `foreign_key`: the column references a primary key in another table (or in the current table, if a self-join). The specific relationship is defined in [`relationships`](#relationships). | ||
| * `primary_key`: the set of columns with the `primary_key` constraint uniquely identifies each row. Implies `required` and `unique`. Not valid on `list` or `struct` columns, or on fields within a `struct`. |
There was a problem hiding this comment.
We could consider consider other carve outs if you think support is going to be complex
There was a problem hiding this comment.
This looks OK for me, although I am not sure what more you would add.
| type: list(enum) | ||
| values: [food, drink, dessert] |
There was a problem hiding this comment.
This looks the same as an enum. What's different here?
There was a problem hiding this comment.
It's a multiselect — an enum must have exactly one value for each row. A list(enum) can have any number of values for each row.
| type: list(string) | ||
| examples: [nature, outdoor, urban, photography, wildlife] |
There was a problem hiding this comment.
Same comment below about the enum. How would this be different?
| - name: address | ||
| type: struct | ||
| fields: | ||
| - name: street | ||
| type: string | ||
| examples: [123 Main St, 456 Oak Ave, 789 Elm Dr] | ||
| - name: city | ||
| type: string | ||
| examples: [Portland, Austin, Chicago] | ||
| - name: zip | ||
| type: string | ||
| examples: ["97201", "78701", "60601"] | ||
| - name: country | ||
| type: enum | ||
| values: [US, CA, MX] |
There was a problem hiding this comment.
I have a hard time seeing the difference here with the list(struct). I understand that the data itself might be different, but when the metadata looks the exact same, I'd have a hard time differentiating them both.
| * `datetime`: date-times, written as ISO 8601 strings. Without a `time_zone` they carry an offset (e.g. `2024-01-31T09:30:00Z`); with a `time_zone` they're written zoneless and interpreted in that zone (see [Time zones](#time-zones)). | ||
| * `enum`: a column with repeated values from a known set. The allowed values are listed in the `values` property. | ||
| * `list(element_type)`: an ordered sequence of zero or more elements of the given type (see [List element types](#list-element-types)). | ||
| * `struct`: a structured record with named fields documented in the required `fields` property (see [Struct fields](#struct-fields)). |
There was a problem hiding this comment.
Are you thinking of using these for very nested data? I personally haven't encountered these "in the wild". What would be the advantage of a list(struct) rather than as either another table or as a flattened set of columns with specific items appended to their column name.
There was a problem hiding this comment.
It's not a data structure that I'd generally recommend, since I would prefer a relation framing with multiple tables, but it is something that you get in parquet files so its important that we can represent it.
|
|
||
| #### Struct fields | ||
|
|
||
| A `struct` column may include a `fields` property — an ordered list of field descriptors. Each field descriptor uses the same schema as a column descriptor. A field may itself be `list(...)` or `struct` (with its own `fields`), allowing deep nesting. |
There was a problem hiding this comment.
So if I understand correctly list(..., struct(list(...)), ...) is allowed, but list(list(...)) is not? Is that intentional? Since the list -> struct -> list nesting is already allowed I don't see why the list(list(...)) would not be.
| * `date`: calendar dates, written as ISO 8601 strings (`YYYY-MM-DD`, e.g. `2024-01-31`). | ||
| * `datetime`: date-times, written as ISO 8601 strings. Without a `time_zone` they carry an offset (e.g. `2024-01-31T09:30:00Z`); with a `time_zone` they're written zoneless and interpreted in that zone (see [Time zones](#time-zones)). | ||
| * `enum`: a column with repeated values from a known set. The allowed values are listed in the `values` property. | ||
| * `list(element_type)`: an ordered sequence of zero or more elements of the given type (see [List element types](#list-element-types)). |
There was a problem hiding this comment.
list definitely. struct is as good as any imo
|
|
||
| * `primary_key`: the set of columns with the `primary_key` constraint uniquely identifies each row. Implies `required` and `unique`. | ||
| * `foreign_key`: the column references a primary key in another table (or in the current table, if a self-join). The specific relationship is defined in [`relationships`](#relationships). | ||
| * `primary_key`: the set of columns with the `primary_key` constraint uniquely identifies each row. Implies `required` and `unique`. Not valid on `list` or `struct` columns, or on fields within a `struct`. |
There was a problem hiding this comment.
This looks OK for me, although I am not sure what more you would add.
|
To do:
|
Will eventually fix #56 and fix #57.