-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow inserting subschemas (#3041)
Allow inserting subset of columns in the schema, if missing columns are nullable. Missing columns will be filled with null values. This even works with nested fields. For example: ```python import lance import pyarrow as pa data = [ {"vec": [1.0, 2.0, 3.0], "metadata": {"x": 1, "y": 2}}, {"metadata": {"x": 3}}, {"vec": [2.0, 3.0, 5.0], "metadata": {"y": 4}}, ] table = pa.Table.from_pylist(data) ds = lance.write_dataset(table, "./demo") ds.to_table().to_pandas() ``` ``` vec metadata 0 [1.0, 2.0, 3.0] {'x': 1.0, 'y': 2.0} 1 None {'x': 3.0, 'y': None} 2 [2.0, 3.0, 5.0] {'x': None, 'y': 4.0} ``` ```python new_data = [ {"metadata": {"y": 6}, "vec": [1.0, 2.0, 3.0]}, ] new_table = pa.Table.from_pylist(new_data) ds = lance.write_dataset(new_table, "./demo", mode="append") ds.to_table().to_pandas() ``` ``` vec metadata 0 [1.0, 2.0, 3.0] {'x': 1.0, 'y': 2.0} 1 None {'x': 3.0, 'y': None} 2 [2.0, 3.0, 5.0] {'x': None, 'y': 4.0} 3 [1.0, 2.0, 3.0] {'x': None, 'y': 6} ``` Closes #3016
- Loading branch information
Showing
19 changed files
with
842 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.