table
BaseScan
¶
Bases: ABC
A base class for all table scans.
Source code in pyiceberg/table/__init__.py
2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 | |
to_duckdb(table_name, connection=None)
¶
Shorthand for loading the Iceberg Table in DuckDB.
Returns:
| Name | Type | Description |
|---|---|---|
DuckDBPyConnection |
DuckDBPyConnection
|
In memory DuckDB connection with the Iceberg table. |
Source code in pyiceberg/table/__init__.py
to_pandas(**kwargs)
¶
Read a Pandas DataFrame eagerly from this Iceberg table.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Materialized Pandas Dataframe from the Iceberg table |
Source code in pyiceberg/table/__init__.py
to_polars()
¶
Read a Polars DataFrame from this Iceberg table.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: Materialized Polars Dataframe from the Iceberg table |
Source code in pyiceberg/table/__init__.py
to_ray()
¶
Read a Ray Dataset eagerly from this Iceberg table.
Returns:
| Type | Description |
|---|---|
Dataset
|
ray.data.dataset.Dataset: Materialized Ray Dataset from the Iceberg table |
Source code in pyiceberg/table/__init__.py
update(**overrides)
¶
Create a copy of this table scan with updated fields.
Source code in pyiceberg/table/__init__.py
CommitTableRequest
¶
Bases: IcebergBaseModel
A pydantic BaseModel for a table commit request.
Source code in pyiceberg/table/__init__.py
CommitTableResponse
¶
Bases: IcebergBaseModel
A pydantic BaseModel for a table commit response.
Source code in pyiceberg/table/__init__.py
CreateTableTransaction
¶
Bases: Transaction
A transaction that involves the creation of a new table.
Source code in pyiceberg/table/__init__.py
commit_transaction()
¶
Commit the changes to the catalog.
In the case of a CreateTableTransaction, the only requirement is AssertCreate. Returns: The table with the updates applied.
Source code in pyiceberg/table/__init__.py
DataScan
¶
Bases: TableScan
Source code in pyiceberg/table/__init__.py
2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 | |
plan_files()
¶
Plans the relevant files by filtering on the PartitionSpecs.
If the table comes from a REST catalog with scan planning enabled, this will use server-side scan planning. Otherwise, it falls back to local planning.
Returns:
| Type | Description |
|---|---|
Iterable[FileScanTask]
|
List of FileScanTasks that contain both data and delete files. |
Source code in pyiceberg/table/__init__.py
to_arrow(dictionary_columns=())
¶
Read an Arrow table eagerly from this DataScan.
All rows will be loaded into memory at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary_columns
|
tuple[str, ...]
|
A tuple of column names that PyArrow should read as
dictionary-encoded ( |
()
|
Returns:
| Type | Description |
|---|---|
Table
|
pa.Table: Materialized Arrow Table from the Iceberg table's DataScan |
Source code in pyiceberg/table/__init__.py
to_arrow_batch_reader(dictionary_columns=())
¶
Return an Arrow RecordBatchReader from this DataScan.
For large results, using a RecordBatchReader requires less memory than loading an Arrow Table for the same DataScan, because a RecordBatch is read one at a time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary_columns
|
tuple[str, ...]
|
A tuple of column names that PyArrow should read as
dictionary-encoded ( |
()
|
Returns:
| Type | Description |
|---|---|
RecordBatchReader
|
pa.RecordBatchReader: Arrow RecordBatchReader from the Iceberg table's DataScan which can be used to read a stream of record batches one by one. |
Source code in pyiceberg/table/__init__.py
FileScanTask
dataclass
¶
Bases: ScanTask
Task representing a data file and its corresponding delete files.
Source code in pyiceberg/table/__init__.py
from_rest_response(rest_task, delete_files)
staticmethod
¶
Convert a RESTFileScanTask to a FileScanTask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rest_task
|
RESTFileScanTask
|
The REST file scan task. |
required |
delete_files
|
list[RESTDeleteFile]
|
The list of delete files from the ScanTasks response. |
required |
Returns:
| Type | Description |
|---|---|
FileScanTask
|
A FileScanTask with the converted data and delete files. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If equality delete files are encountered. |
Source code in pyiceberg/table/__init__.py
IncrementalAppendScan
¶
Bases: BaseScan
An incremental scan of a table's data that accumulates appended data between two snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_snapshot_id
|
int | None
|
ID of the snapshot to start the incremental scan from. If None, the scan starts from the oldest ancestor of the "to" snapshot (inclusive). |
None
|
from_snapshot_inclusive
|
bool
|
Whether from_snapshot_id is included in the scan. If False, the start snapshot is exclusive. |
False
|
to_snapshot_id
|
int | None
|
Optional ID of the snapshot to end the incremental scan at, inclusively. Omitting it will default to the table's current snapshot. |
None
|
row_filter
|
str | BooleanExpression
|
A string or BooleanExpression that describes the desired rows |
ALWAYS_TRUE
|
selected_fields
|
tuple[str, ...]
|
A tuple of strings representing the column names to return in the output dataframe. |
('*',)
|
case_sensitive
|
bool
|
If True column matching is case sensitive |
True
|
options
|
Properties
|
Additional Table properties as a dictionary of string key value pairs to use for this scan. |
EMPTY_DICT
|
limit
|
int | None
|
An integer representing the number of rows to return in the scan result. If None, fetches all matching rows. |
None
|
Source code in pyiceberg/table/__init__.py
2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 | |
from_snapshot_id_exclusive(from_snapshot_id)
¶
Return a copy of this scan that starts (exclusively) from the given snapshot ID.
Source code in pyiceberg/table/__init__.py
from_snapshot_id_inclusive(from_snapshot_id)
¶
Return a copy of this scan that starts (inclusively) from the given snapshot ID.
Source code in pyiceberg/table/__init__.py
plan_files()
¶
Plans the relevant files added between the specified snapshots.
Source code in pyiceberg/table/__init__.py
to_arrow()
¶
Read an Arrow table eagerly from this IncrementalAppendScan.
All rows will be loaded into memory at once.
Returns:
| Type | Description |
|---|---|
Table
|
pa.Table: Materialized Arrow Table from the Iceberg table's IncrementalAppendScan |
Source code in pyiceberg/table/__init__.py
to_arrow_batch_reader()
¶
Return an Arrow RecordBatchReader from this IncrementalAppendScan.
For large results, using a RecordBatchReader requires less memory than loading an Arrow Table for the same IncrementalAppendScan, because a RecordBatch is read one at a time.
Returns:
| Type | Description |
|---|---|
RecordBatchReader
|
pa.RecordBatchReader: Arrow RecordBatchReader from the Iceberg table's IncrementalAppendScan which can be used to read a stream of record batches one by one. |
Source code in pyiceberg/table/__init__.py
to_snapshot_id_inclusive(to_snapshot_id)
¶
Return a copy of this scan that ends (inclusively) at the given snapshot ID.
ManifestGroupPlanner
¶
Plans the scan tasks for a group of manifests.
Source code in pyiceberg/table/__init__.py
2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 | |
plan_files(manifests, manifest_entry_filter=lambda _: True)
¶
Plan the file scan tasks for the given manifests.
manifest_entry_filter is an additional predicate applied after the partition
evaluator; entries for which it returns False are excluded from the result.
Returns:
| Type | Description |
|---|---|
Iterable[FileScanTask]
|
List of FileScanTasks that contain both data and delete files. |
Source code in pyiceberg/table/__init__.py
plan_manifest_entries(manifests)
¶
Filter the given manifests using partition summaries and read the matching manifest entries.
For each manifest that passes the partition-summary filter, returns a list of its manifest entries that match the partition and metrics evaluators. The returned iterator yields one list per manifest (in parallel).
Source code in pyiceberg/table/__init__.py
Namespace
¶
Bases: IcebergRootModel[list[str]]
Reference to one or more levels of a namespace.
Source code in pyiceberg/table/__init__.py
StaticTable
¶
Bases: Table
Load a table directly from a metadata file (i.e., without using a catalog).
Source code in pyiceberg/table/__init__.py
Table
¶
An Iceberg table.
Source code in pyiceberg/table/__init__.py
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 | |
inspect
property
¶
Return the InspectTable object to browse the table metadata.
Returns:
| Type | Description |
|---|---|
InspectTable
|
InspectTable object based on this Table. |
maintenance
property
¶
Return the MaintenanceTable object for maintenance.
Returns:
| Type | Description |
|---|---|
MaintenanceTable
|
MaintenanceTable object based on this Table. |
properties
property
¶
Properties of the table.
__datafusion_table_provider__(session=None)
¶
Return the DataFusion table provider PyCapsule interface.
To support DataFusion features such as push down filtering, this function will return a PyCapsule
interface that conforms to the FFI Table Provider required by DataFusion. From an end user perspective
you should not need to call this function directly. Instead you can use register_table in
the DataFusion SessionContext.
Returns:
| Type | Description |
|---|---|
IcebergDataFusionTable
|
A PyCapsule DataFusion TableProvider interface. |
Example
from datafusion import SessionContext
from pyiceberg.catalog import load_catalog
import pyarrow as pa
catalog = load_catalog("catalog", type="in-memory")
catalog.create_namespace_if_not_exists("default")
data = pa.table({"x": [1, 2, 3], "y": [4, 5, 6]})
iceberg_table = catalog.create_table("default.test", schema=data.schema)
iceberg_table.append(data)
ctx = SessionContext()
ctx.register_table("test", iceberg_table)
ctx.table("test").show()
Source code in pyiceberg/table/__init__.py
__eq__(other)
¶
Return the equality of two instances of the Table class.
Source code in pyiceberg/table/__init__.py
__repr__()
¶
Return the string representation of the Table class.
Source code in pyiceberg/table/__init__.py
add_files(file_paths, snapshot_properties=EMPTY_DICT, check_duplicate_files=True, branch=MAIN_BRANCH)
¶
Shorthand API for adding files as data files to the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_paths
|
list[str]
|
The list of full file paths to be added as data files to the table |
required |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
Source code in pyiceberg/table/__init__.py
append(df, snapshot_properties=EMPTY_DICT, branch=MAIN_BRANCH)
¶
Shorthand API for appending PyArrow data to the table.
Accepts either a pa.Table or a streaming pa.RecordBatchReader.
See :meth:Transaction.append for streaming semantics and partition
limitations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
Table | RecordBatchReader
|
An Arrow Table or a RecordBatchReader of records to append. |
required |
snapshot_properties
|
dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
branch
|
str | None
|
Branch Reference to run the append operation |
MAIN_BRANCH
|
Source code in pyiceberg/table/__init__.py
current_snapshot()
¶
Get the current snapshot for this table, or None if there is no current snapshot.
Source code in pyiceberg/table/__init__.py
delete(delete_filter=ALWAYS_TRUE, snapshot_properties=EMPTY_DICT, case_sensitive=True, branch=MAIN_BRANCH)
¶
Shorthand for deleting rows from the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delete_filter
|
BooleanExpression | str
|
The predicate that used to remove rows |
ALWAYS_TRUE
|
snapshot_properties
|
dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
case_sensitive
|
bool
|
A bool determine if the provided |
True
|
branch
|
str | None
|
Branch Reference to run the delete operation |
MAIN_BRANCH
|
Source code in pyiceberg/table/__init__.py
dynamic_partition_overwrite(df, snapshot_properties=EMPTY_DICT, branch=MAIN_BRANCH)
¶
Shorthand for dynamic overwriting the table with a PyArrow table.
Old partitions are auto detected and replaced with data files created for input arrow table. Args: df: The Arrow dataframe that will be used to overwrite the table snapshot_properties: Custom properties to be added to the snapshot summary branch: Branch Reference to run the dynamic partition overwrite operation
Source code in pyiceberg/table/__init__.py
history()
¶
incremental_append_scan(*, from_snapshot_id_exclusive=None, to_snapshot_id_inclusive=None, row_filter=ALWAYS_TRUE, selected_fields=('*',), case_sensitive=True, options=EMPTY_DICT, limit=None)
¶
Fetch an IncrementalAppendScan based on the table's current metadata.
The incremental append scan returns the rows added by append snapshots in a snapshot range that match the provided row_filter, projected onto the table's current schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_snapshot_id_exclusive
|
int | None
|
Optional ID of the snapshot to start the incremental scan from, exclusively. If not set, the scan starts from the oldest ancestor of the end snapshot (inclusive). |
None
|
to_snapshot_id_inclusive
|
int | None
|
Optional ID of the snapshot to end the incremental scan at, inclusively. If not set, it defaults to the table's current snapshot. |
None
|
row_filter
|
str | BooleanExpression
|
A string or BooleanExpression that describes the desired rows. |
ALWAYS_TRUE
|
selected_fields
|
tuple[str, ...]
|
A tuple of strings representing the column names to return in the output dataframe. |
('*',)
|
case_sensitive
|
bool
|
If True column matching is case sensitive. |
True
|
options
|
Properties
|
Additional Table properties as a dictionary of string key value pairs to use for this scan. |
EMPTY_DICT
|
limit
|
int | None
|
An integer representing the number of rows to return in the scan result. If None, fetches all matching rows. |
None
|
Returns:
| Type | Description |
|---|---|
IncrementalAppendScan
|
An IncrementalAppendScan based on the table's current metadata and provided parameters. |
Source code in pyiceberg/table/__init__.py
last_partition_id()
¶
Return the highest assigned partition field ID across all specs or 999 if only the unpartitioned spec exists.
Source code in pyiceberg/table/__init__.py
location()
¶
location_provider()
¶
manage_snapshots()
¶
Shorthand to run snapshot management operations like create branch, create tag, etc.
Use table.manage_snapshots().
We can also use context managers to make more changes. For example,
with table.manage_snapshots() as ms: ms.create_tag(snapshot_id1, "Tag_A").create_tag(snapshot_id2, "Tag_B")
Source code in pyiceberg/table/__init__.py
name()
¶
Return the identifier of this table.
Returns:
| Type | Description |
|---|---|
Identifier
|
An Identifier tuple of the table name |
name_mapping()
¶
overwrite(df, overwrite_filter=ALWAYS_TRUE, snapshot_properties=EMPTY_DICT, case_sensitive=True, branch=MAIN_BRANCH)
¶
Shorthand for overwriting the table with a PyArrow Table or RecordBatchReader.
Accepts either a pa.Table or a streaming pa.RecordBatchReader.
See :meth:Transaction.overwrite for streaming semantics and partition
limitations.
An overwrite may produce zero or more snapshots based on the operation:
- DELETE: In case existing Parquet files can be dropped completely.
- OVERWRITE: In case existing Parquet files need to be rewritten to drop rows that match the overwrite filter..
- APPEND: In case new data is being inserted into the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
Table | RecordBatchReader
|
An Arrow Table or a RecordBatchReader of records to write. |
required |
overwrite_filter
|
BooleanExpression | str
|
ALWAYS_TRUE when you overwrite all the data, or a boolean expression in case of a partial overwrite |
ALWAYS_TRUE
|
snapshot_properties
|
dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
case_sensitive
|
bool
|
A bool determine if the provided |
True
|
branch
|
str | None
|
Branch Reference to run the overwrite operation |
MAIN_BRANCH
|
Source code in pyiceberg/table/__init__.py
refresh()
¶
Refresh the current table metadata.
Returns:
| Type | Description |
|---|---|
Table
|
An updated instance of the same Iceberg table |
Source code in pyiceberg/table/__init__.py
refs()
¶
scan(row_filter=ALWAYS_TRUE, selected_fields=('*',), case_sensitive=True, snapshot_id=None, options=EMPTY_DICT, limit=None)
¶
Fetch a DataScan based on the table's current metadata.
The data scan can be used to project the table's data
that matches the provided row_filter onto the table's
current schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row_filter
|
str | BooleanExpression
|
A string or BooleanExpression that describes the desired rows |
ALWAYS_TRUE
|
selected_fields
|
tuple[str, ...]
|
A tuple of strings representing the column names to return in the output dataframe. |
('*',)
|
case_sensitive
|
bool
|
If True column matching is case sensitive |
True
|
snapshot_id
|
int | None
|
Optional Snapshot ID to time travel to. If None, scans the table as of the current snapshot ID. |
None
|
options
|
Properties
|
Additional Table properties as a dictionary of string key value pairs to use for this scan. |
EMPTY_DICT
|
limit
|
int | None
|
An integer representing the number of rows to return in the scan result. If None, fetches all matching rows. |
None
|
Returns:
| Type | Description |
|---|---|
DataScan
|
A DataScan based on the table's current metadata. |
Source code in pyiceberg/table/__init__.py
schema()
¶
schemas()
¶
snapshot_as_of_timestamp(timestamp_ms, inclusive=True)
¶
Get the snapshot that was current as of or right before the given timestamp, or None if there is no matching snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp_ms
|
int
|
Find snapshot that was current at/before this timestamp |
required |
inclusive
|
bool
|
Includes timestamp_ms in search when True. Excludes timestamp_ms when False |
True
|
Source code in pyiceberg/table/__init__.py
snapshot_by_id(snapshot_id)
¶
Get the snapshot of this table with the given id, or None if there is no matching snapshot.
snapshot_by_name(name)
¶
Return the snapshot referenced by the given name or null if no such reference exists.
Source code in pyiceberg/table/__init__.py
sort_order()
¶
Return the sort order of this table.
sort_orders()
¶
spec()
¶
specs()
¶
to_bodo()
¶
Read a bodo DataFrame lazily from this Iceberg table.
Returns:
| Type | Description |
|---|---|
DataFrame
|
bd.DataFrame: Unmaterialized Bodo Dataframe created from the Iceberg table |
Source code in pyiceberg/table/__init__.py
to_daft()
¶
Read a Daft DataFrame lazily from this Iceberg table.
Returns:
| Type | Description |
|---|---|
DataFrame
|
daft.DataFrame: Unmaterialized Daft Dataframe created from the Iceberg table |
Source code in pyiceberg/table/__init__.py
to_polars()
¶
Lazily read from this Apache Iceberg table.
Returns:
| Type | Description |
|---|---|
LazyFrame
|
pl.LazyFrame: Unmaterialized Polars LazyFrame created from the Iceberg table |
Source code in pyiceberg/table/__init__.py
transaction()
¶
Create a new transaction object to first stage the changes, and then commit them to the catalog.
Returns:
| Type | Description |
|---|---|
Transaction
|
The transaction object |
update_schema(allow_incompatible_changes=False, case_sensitive=True)
¶
Create a new UpdateSchema to alter the columns of this table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allow_incompatible_changes
|
bool
|
If changes are allowed that might break downstream consumers. |
False
|
case_sensitive
|
bool
|
If field names are case-sensitive. |
True
|
Returns:
| Type | Description |
|---|---|
UpdateSchema
|
A new UpdateSchema. |
Source code in pyiceberg/table/__init__.py
update_sort_order(case_sensitive=True)
¶
Create a new UpdateSortOrder to update the sort order of this table.
Returns:
| Type | Description |
|---|---|
UpdateSortOrder
|
A new UpdateSortOrder. |
Source code in pyiceberg/table/__init__.py
update_statistics()
¶
Shorthand to run statistics management operations like add statistics and remove statistics.
Use table.update_statistics().
Pending changes are applied on commit.
We can also use context managers to make more changes. For example:
with table.update_statistics() as update: update.set_statistics(statistics_file=statistics_file) update.remove_statistics(snapshot_id=2)
Source code in pyiceberg/table/__init__.py
upsert(df, join_cols=None, when_matched_update_all=True, when_not_matched_insert_all=True, case_sensitive=True, branch=MAIN_BRANCH, snapshot_properties=EMPTY_DICT)
¶
Shorthand API for performing an upsert to an iceberg table.
Args:
df: The input dataframe to upsert with the table's data.
join_cols: Columns to join on, if not provided, it will use the identifier-field-ids.
when_matched_update_all: Bool indicating to update rows that are matched but require an update
due to a value in a non-key column changing
when_not_matched_insert_all: Bool indicating new rows to be inserted that do not match any
existing rows in the table
case_sensitive: Bool indicating if the match should be case-sensitive
branch: Branch Reference to run the upsert operation
snapshot_properties: Custom properties to be added to the snapshot summary
To learn more about the identifier-field-ids: https://iceberg.apache.org/spec/#identifier-field-ids
Example Use Cases:
Case 1: Both Parameters = True (Full Upsert)
Existing row found → Update it
New row found → Insert it
Case 2: when_matched_update_all = False, when_not_matched_insert_all = True
Existing row found → Do nothing (no updates)
New row found → Insert it
Case 3: when_matched_update_all = True, when_not_matched_insert_all = False
Existing row found → Update it
New row found → Do nothing (no inserts)
Case 4: Both Parameters = False (No Merge Effect)
Existing row found → Do nothing
New row found → Do nothing
(Function effectively does nothing)
Returns:
| Type | Description |
|---|---|
UpsertResult
|
An UpsertResult class (contains details of rows updated and inserted) |
Source code in pyiceberg/table/__init__.py
TableIdentifier
¶
TableScan
¶
Bases: BaseScan
A base class for table scans targeting a single snapshot.
Source code in pyiceberg/table/__init__.py
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 | |
Transaction
¶
Source code in pyiceberg/table/__init__.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 | |
__enter__()
¶
__exit__(exctype, excinst, exctb)
¶
Close and commit the transaction if no exceptions have been raised.
Source code in pyiceberg/table/__init__.py
__init__(table, autocommit=False)
¶
Open a transaction to stage and commit changes to a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
The table that will be altered. |
required |
autocommit
|
bool
|
Option to automatically commit the changes when they are staged. |
False
|
Source code in pyiceberg/table/__init__.py
add_files(file_paths, snapshot_properties=EMPTY_DICT, check_duplicate_files=True, branch=MAIN_BRANCH)
¶
Shorthand API for adding files as data files to the table transaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_paths
|
list[str]
|
The list of full file paths to be added as data files to the table |
required |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
ValueError
|
Raises a ValueError given file_paths contains duplicate files |
ValueError
|
Raises a ValueError given file_paths already referenced by table |
Source code in pyiceberg/table/__init__.py
append(df, snapshot_properties=EMPTY_DICT, branch=MAIN_BRANCH)
¶
Shorthand API for appending PyArrow data to a table transaction.
Accepts either a fully materialised pa.Table or a streaming
pa.RecordBatchReader. Streaming is microbatched by
write.target-file-size-bytes so memory stays bounded; the reader is
consumed once and cannot be reused.
Streaming writes are currently only supported on unpartitioned tables;
passing a pa.RecordBatchReader for a partitioned table raises
NotImplementedError. See
https://github.com/apache/iceberg-python/issues/2152.
Note
When df is a pa.RecordBatchReader the reader is consumed
once and cannot be replayed. If the catalog commit fails (e.g.
CommitFailedException from a concurrent writer) the reader is
already drained and a naive retry will append zero rows. Callers
that need at-least-once semantics should either:
- reconstruct the reader on each attempt via a factory callable, or
- use a two-stage pattern — write Parquet files explicitly and
then call :meth:
add_files(whose input is a replayable list of paths) within a retry loop.
Failures during the write stage (mid-stream reader exception, S3 errors) do not commit a snapshot, but may leave orphan data files in storage that are not referenced by any snapshot. Clean these up with expire/orphan-file maintenance jobs.
write.target-file-size-bytes is currently interpreted as
uncompressed in-memory Arrow bytes (the bin-packing weight) rather
than compressed on-disk Parquet bytes. The resulting files are
typically 3-10× smaller than the property suggests after
compression. This matches the existing pa.Table write path and
will be tightened once the writer is switched to a
rolling-ParquetWriter with OutputStream.tell() (#2998).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
Table | RecordBatchReader
|
An Arrow Table or a RecordBatchReader of records to append. |
required |
snapshot_properties
|
dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
branch
|
str | None
|
Branch Reference to run the append operation |
MAIN_BRANCH
|
Source code in pyiceberg/table/__init__.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
commit_transaction()
¶
Commit the changes to the catalog.
Returns:
| Type | Description |
|---|---|
Table
|
The table with the updates applied. |
Source code in pyiceberg/table/__init__.py
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | |
delete(delete_filter, snapshot_properties=EMPTY_DICT, case_sensitive=True, branch=MAIN_BRANCH, _isolation_operation=None)
¶
Shorthand for deleting record from a table.
A delete may produce zero or more snapshots based on the operation:
- DELETE: In case existing Parquet files can be dropped completely.
- OVERWRITE: In case existing Parquet files need to be rewritten to drop rows that match the delete filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delete_filter
|
str | BooleanExpression
|
A boolean expression to delete rows from a table |
required |
snapshot_properties
|
dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
case_sensitive
|
bool
|
A bool determine if the provided |
True
|
branch
|
str | None
|
Branch Reference to run the delete operation |
MAIN_BRANCH
|
Source code in pyiceberg/table/__init__.py
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | |
dynamic_partition_overwrite(df, snapshot_properties=EMPTY_DICT, branch=MAIN_BRANCH)
¶
Shorthand for overwriting existing partitions with a PyArrow table.
The function detects partition values in the provided arrow table using the current partition spec, and deletes existing partitions matching these values. Finally, the data in the table is appended to the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
Table
|
The Arrow dataframe that will be used to overwrite the table |
required |
snapshot_properties
|
dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
branch
|
str | None
|
Branch Reference to run the dynamic partition overwrite operation |
MAIN_BRANCH
|
Source code in pyiceberg/table/__init__.py
overwrite(df, overwrite_filter=ALWAYS_TRUE, snapshot_properties=EMPTY_DICT, case_sensitive=True, branch=MAIN_BRANCH)
¶
Shorthand for adding a table overwrite with a PyArrow table or RecordBatchReader to the transaction.
Accepts either a fully materialised pa.Table or a streaming
pa.RecordBatchReader. Streaming is microbatched by
write.target-file-size-bytes so memory stays bounded; the reader is
consumed once and cannot be reused.
Streaming writes are currently only supported on unpartitioned tables;
passing a pa.RecordBatchReader for a partitioned table raises
NotImplementedError. See
https://github.com/apache/iceberg-python/issues/2152.
Note
When df is a pa.RecordBatchReader the reader is consumed
once and cannot be replayed. If the catalog commit fails (e.g.
CommitFailedException from a concurrent writer) the reader is
already drained and a naive retry will write zero rows. Callers
that need at-least-once semantics should either:
- reconstruct the reader on each attempt via a factory callable, or
- use a two-stage pattern — write Parquet files explicitly and
then call :meth:
add_files(whose input is a replayable list of paths) within a retry loop.
Failures during the write stage (mid-stream reader exception, S3 errors) do not commit a snapshot, but may leave orphan data files in storage that are not referenced by any snapshot. Clean these up with expire/orphan-file maintenance jobs.
write.target-file-size-bytes is currently interpreted as
uncompressed in-memory Arrow bytes (the bin-packing weight) rather
than compressed on-disk Parquet bytes. The resulting files are
typically 3-10× smaller than the property suggests after
compression. This matches the existing pa.Table write path and
will be tightened once the writer is switched to a
rolling-ParquetWriter with OutputStream.tell() (#2998).
An overwrite may produce zero or more snapshots based on the operation:
- DELETE: In case existing Parquet files can be dropped completely.
- OVERWRITE: In case existing Parquet files need to be rewritten to drop rows that match the overwrite filter.
- APPEND: In case new data is being inserted into the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
Table | RecordBatchReader
|
An Arrow Table or a RecordBatchReader of records to write. |
required |
overwrite_filter
|
BooleanExpression | str
|
ALWAYS_TRUE when you overwrite all the data, or a boolean expression in case of a partial overwrite |
ALWAYS_TRUE
|
snapshot_properties
|
dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
case_sensitive
|
bool
|
A bool determine if the provided |
True
|
branch
|
str | None
|
Branch Reference to run the overwrite operation |
MAIN_BRANCH
|
Source code in pyiceberg/table/__init__.py
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | |
remove_properties(*removals)
¶
Remove properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
removals
|
str
|
Properties to be removed. |
()
|
Returns:
| Type | Description |
|---|---|
Transaction
|
The alter table builder. |
Source code in pyiceberg/table/__init__.py
set_properties(properties=EMPTY_DICT, **kwargs)
¶
Set properties.
When a property is already set, it will be overwritten.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
properties
|
Properties
|
The properties set on the table. |
EMPTY_DICT
|
kwargs
|
Any
|
properties can also be pass as kwargs. |
{}
|
Returns:
| Type | Description |
|---|---|
Transaction
|
The alter table builder. |
Source code in pyiceberg/table/__init__.py
update_location(location)
¶
Set the new table location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
The new location of the table. |
required |
Returns:
| Type | Description |
|---|---|
Transaction
|
The alter table builder. |
Source code in pyiceberg/table/__init__.py
update_schema(allow_incompatible_changes=False, case_sensitive=True)
¶
Create a new UpdateSchema to alter the columns of this table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allow_incompatible_changes
|
bool
|
If changes are allowed that might break downstream consumers. |
False
|
case_sensitive
|
bool
|
If field names are case-sensitive. |
True
|
Returns:
| Type | Description |
|---|---|
UpdateSchema
|
A new UpdateSchema. |
Source code in pyiceberg/table/__init__.py
update_snapshot(snapshot_properties=EMPTY_DICT, branch=MAIN_BRANCH)
¶
Create a new UpdateSnapshot to produce a new snapshot for the table.
Returns:
| Type | Description |
|---|---|
UpdateSnapshot
|
A new UpdateSnapshot |
Source code in pyiceberg/table/__init__.py
update_sort_order(case_sensitive=True)
¶
Create a new UpdateSortOrder to update the sort order of this table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
case_sensitive
|
bool
|
If field names are case-sensitive. |
True
|
Returns:
| Type | Description |
|---|---|
UpdateSortOrder
|
A new UpdateSortOrder. |
Source code in pyiceberg/table/__init__.py
update_spec()
¶
Create a new UpdateSpec to update the partitioning of the table.
Returns:
| Type | Description |
|---|---|
UpdateSpec
|
A new UpdateSpec. |
update_statistics()
¶
Create a new UpdateStatistics to update the statistics of the table.
Returns:
| Type | Description |
|---|---|
UpdateStatistics
|
A new UpdateStatistics |
upgrade_table_version(format_version)
¶
Set the table to a certain version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format_version
|
TableVersion
|
The newly set version. |
required |
Returns:
| Type | Description |
|---|---|
Transaction
|
The alter table builder. |
Source code in pyiceberg/table/__init__.py
upsert(df, join_cols=None, when_matched_update_all=True, when_not_matched_insert_all=True, case_sensitive=True, branch=MAIN_BRANCH, snapshot_properties=EMPTY_DICT)
¶
Shorthand API for performing an upsert to an iceberg table.
Args:
df: The input dataframe to upsert with the table's data.
join_cols: Columns to join on, if not provided, it will use the identifier-field-ids.
when_matched_update_all: Bool indicating to update rows that are matched but require an update
due to a value in a non-key column changing
when_not_matched_insert_all: Bool indicating new rows to be inserted that do not match any
existing rows in the table
case_sensitive: Bool indicating if the match should be case-sensitive
branch: Branch Reference to run the upsert operation
snapshot_properties: Custom properties to be added to the snapshot summary
To learn more about the identifier-field-ids: https://iceberg.apache.org/spec/#identifier-field-ids
Example Use Cases:
Case 1: Both Parameters = True (Full Upsert)
Existing row found → Update it
New row found → Insert it
Case 2: when_matched_update_all = False, when_not_matched_insert_all = True
Existing row found → Do nothing (no updates)
New row found → Insert it
Case 3: when_matched_update_all = True, when_not_matched_insert_all = False
Existing row found → Update it
New row found → Do nothing (no inserts)
Case 4: Both Parameters = False (No Merge Effect)
Existing row found → Do nothing
New row found → Do nothing
(Function effectively does nothing)
Returns:
| Type | Description |
|---|---|
UpsertResult
|
An UpsertResult class (contains details of rows updated and inserted) |
Source code in pyiceberg/table/__init__.py
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | |
UpsertResult
dataclass
¶
WriteTask
dataclass
¶
Task with the parameters for writing a DataFile.