Skip to content

Commit a95f9ee

Browse files
jeppe-dosJeppe Finne Sørensenkevinjqliu
authored
Change dot notation in add column documentation to tuple (#1433)
* Change dot notation in add column documentation to tuple * Update move and rename column struct in api.md * Correct rename_column, move_before and delete_column in api.md * Change exchange to processed by on rename_column in api.md * Update mkdocs/docs/api.md Co-authored-by: Kevin Liu <[email protected]> * Fix rename column in api.md * Update mkdocs/docs/api.md * Update mkdocs/docs/api.md --------- Co-authored-by: Jeppe Finne Sørensen <[email protected]> Co-authored-by: Kevin Liu <[email protected]>
1 parent c9249c3 commit a95f9ee

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

mkdocs/docs/api.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,12 @@ Using `add_column` you can add a column, without having to worry about the field
10721072
with table.update_schema() as update:
10731073
update.add_column("retries", IntegerType(), "Number of retries to place the bid")
10741074
# In a struct
1075-
update.add_column("details.confirmed_by", StringType(), "Name of the exchange")
1075+
update.add_column("details", StructType())
1076+
1077+
with table.update_schema() as update:
1078+
update.add_column(("details", "confirmed_by"), StringType(), "Name of the exchange")
10761079
```
1080+
A complex type must exist before columns can be added to it. Fields in complex types are added in a tuple.
10771081

10781082
### Rename column
10791083

@@ -1082,20 +1086,21 @@ Renaming a field in an Iceberg table is simple:
10821086
```python
10831087
with table.update_schema() as update:
10841088
update.rename_column("retries", "num_retries")
1085-
# This will rename `confirmed_by` to `exchange`
1086-
update.rename_column("properties.confirmed_by", "exchange")
1089+
# This will rename `confirmed_by` to `processed_by` in the `details` struct
1090+
update.rename_column(("details", "confirmed_by"), "processed_by")
10871091
```
10881092

10891093
### Move column
10901094

1091-
Move a field inside of struct:
1095+
Move order of fields:
10921096

10931097
```python
10941098
with table.update_schema() as update:
10951099
update.move_first("symbol")
1100+
# This will move `bid` after `ask`
10961101
update.move_after("bid", "ask")
1097-
# This will move `confirmed_by` before `exchange`
1098-
update.move_before("details.created_by", "details.exchange")
1102+
# This will move `confirmed_by` before `exchange` in the `details` struct
1103+
update.move_before(("details", "confirmed_by"), ("details", "exchange"))
10991104
```
11001105

11011106
### Update column
@@ -1127,6 +1132,8 @@ Delete a field, careful this is a incompatible change (readers/writers might exp
11271132
```python
11281133
with table.update_schema(allow_incompatible_changes=True) as update:
11291134
update.delete_column("some_field")
1135+
# In a struct
1136+
update.delete_column(("details", "confirmed_by"))
11301137
```
11311138

11321139
## Partition evolution

0 commit comments

Comments
 (0)