Skip to content

Commit 4dac6f5

Browse files
Organize ARRAY updates by responsibility and preserve typed values
1 parent 14df30b commit 4dac6f5

7 files changed

Lines changed: 491 additions & 408 deletions

File tree

‎docs/sqlalchemy.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,11 +1124,16 @@ Use indexed or sliced columns as UPDATE assignment keys on Iceberg tables.
11241124
PyAthena compiles each assignment into a single server-side UPDATE of the whole array.
11251125
Other columns can be assigned in the same statement.
11261126

1127+
For an existing Iceberg table named `orders` with an ARRAY column `item_ids`:
1128+
11271129
```python
1128-
numbers = table.c.numbers
1130+
from sqlalchemy import MetaData, Table
1131+
1132+
orders = Table("orders", MetaData(), autoload_with=engine)
1133+
item_ids = orders.c.item_ids
11291134
with engine.begin() as conn:
1130-
conn.execute(table.update().values({numbers[2]: 10}))
1131-
conn.execute(table.update().values({numbers[2:3]: [20, 30, 40]}))
1135+
conn.execute(orders.update().values({item_ids[2]: 10}))
1136+
conn.execute(orders.update().values({item_ids[2:3]: [20, 30, 40]}))
11321137
```
11331138

11341139
Element assignment beyond the end extends the array and fills intervening positions with NULL.
@@ -1150,6 +1155,7 @@ A slice replacement must be a non-NULL array; use `[]` to delete elements.
11501155
Only `step=None` and `step=1` are supported, and only the final component of a nested update path may be a slice.
11511156
PyAthena rejects multiple partial assignments to the same array column, or a partial assignment combined with a whole-column assignment to that column.
11521157
Use one whole-array expression when an update needs several changes to the same array.
1158+
Partial updates can evaluate indices, boundaries, and replacement SQL expressions more than once; use deterministic expressions.
11531159

11541160
#### Querying ARRAY data
11551161

‎pyathena/sqlalchemy/_array_update.py‎

Lines changed: 0 additions & 220 deletions
This file was deleted.

0 commit comments

Comments
 (0)