@@ -1072,30 +1072,36 @@ Using `add_column` you can add a column, without having to worry about the field
10721072with 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` ` `
10771080
1081+ A complex type must exist before columns can be added to it. Fields in complex types are added in a tuple.
1082+
10781083# ## Rename column
10791084
10801085Renaming a field in an Iceberg table is simple :
10811086
10821087` ` ` python
10831088with table.update_schema() as update:
10841089 update.rename_column("retries", "num_retries")
1085- # This will rename ` confirmed_by` to `exchange`
1086- update.rename_column("properties. confirmed_by", "exchange ")
1090+ # This will rename ` confirmed_by` to `processed_by` in the `details` struct
1091+ update.rename_column(("details", " confirmed_by") , "processed_by ")
10871092```
10881093
10891094### Move column
10901095
1091- Move a field inside of struct :
1096+ Move order of fields :
10921097
10931098``` python
10941099with table.update_schema() as update:
10951100 update.move_first(" symbol" )
1101+ # This will move `bid` after `ask`
10961102 update.move_after(" bid" , " ask" )
1097- # This will move `confirmed_by` before `exchange`
1098- update.move_before(" details.created_by " , " details. exchange" )
1103+ # This will move `confirmed_by` before `exchange` in the `details` struct
1104+ update.move_before(( " details" , " confirmed_by " ), ( " details" , " exchange" ) )
10991105```
11001106
11011107### Update column
@@ -1127,6 +1133,8 @@ Delete a field, careful this is a incompatible change (readers/writers might exp
11271133``` python
11281134with table.update_schema(allow_incompatible_changes = True ) as update:
11291135 update.delete_column(" some_field" )
1136+ # In a struct
1137+ update.delete_column((" details" , " confirmed_by" ))
11301138```
11311139
11321140## Partition evolution
@@ -1250,6 +1258,29 @@ with table.manage_snapshots() as ms:
12501258 ms.create_branch(snapshot_id1, " Branch_A" ).create_tag(snapshot_id2, " tag789" )
12511259```
12521260
1261+ ## Table Statistics Management
1262+
1263+ Manage table statistics with operations through the ` Table ` API:
1264+
1265+ ``` python
1266+ # To run a specific operation
1267+ table.update_statistics().set_statistics(statistics_file = statistics_file).commit()
1268+ # To run multiple operations
1269+ table.update_statistics()
1270+ .set_statistics(statistics_file1)
1271+ .remove_statistics(snapshot_id2)
1272+ .commit()
1273+ # Operations are applied on commit.
1274+ ```
1275+
1276+ You can also use context managers to make more changes:
1277+
1278+ ``` python
1279+ with table.update_statistics() as update:
1280+ update.set_statistics(statistics_file)
1281+ update.remove_statistics(snapshot_id2)
1282+ ```
1283+
12531284## Query the data
12541285
12551286To query a table, a table scan is needed. A table scan accepts a filter, columns, optionally a limit and a snapshot ID:
0 commit comments