table
AddFileTask
dataclass
¶
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 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
1312 1313 1314 1315 1316 1317 1318 1319 1320 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 |
|
plan_files()
¶
Plans the relevant files by filtering on the PartitionSpecs.
Returns:
Type | Description |
---|---|
Iterable[FileScanTask]
|
List of FileScanTasks that contain both data and delete files. |
Source code in pyiceberg/table/__init__.py
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 |
|
to_arrow()
¶
Read an Arrow table eagerly from this DataScan.
All rows will be loaded into memory at once.
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()
¶
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.
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
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_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
FileScanTask
dataclass
¶
Bases: ScanTask
Task representing a data file and its corresponding delete files.
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
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 |
|
identifier: Identifier
property
¶
Return the identifier of this table.
Returns:
Type | Description |
---|---|
Identifier
|
An Identifier tuple of the table name |
inspect: InspectTable
property
¶
Return the InspectTable object to browse the table metadata.
Returns:
Type | Description |
---|---|
InspectTable
|
InspectTable object based on this Table. |
properties: Dict[str, str]
property
¶
Properties of the table.
__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)
¶
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)
¶
Shorthand API for appending a PyArrow table to the table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
Table
|
The Arrow dataframe that will be appended to overwrite the table |
required |
snapshot_properties
|
Dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
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)
¶
Shorthand for deleting rows from the table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delete_filter
|
Union[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
|
Source code in pyiceberg/table/__init__.py
history()
¶
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()
¶
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)
¶
Shorthand for overwriting the table with a PyArrow table.
An overwrite may produce zero or more snapshots based on the operation:
- DELETE: In case existing Parquet files can be dropped completely.
- REPLACE: In case existing Parquet files need to be rewritten.
- APPEND: In case new data is being inserted into the table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
Table
|
The Arrow dataframe that will be used to overwrite the table |
required |
overwrite_filter
|
Union[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
|
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
|
Union[str, BooleanExpression]
|
A string or BooleanExpression that decsribes 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
|
Optional[int]
|
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
|
Optional[int]
|
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_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
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
TableIdentifier
¶
TableScan
¶
Bases: ABC
Source code in pyiceberg/table/__init__.py
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 |
|
Transaction
¶
Source code in pyiceberg/table/__init__.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 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 |
|
__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)
¶
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)
¶
Shorthand API for appending a PyArrow table to a table transaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
Table
|
The Arrow dataframe that will be appended to overwrite the table |
required |
snapshot_properties
|
Dict[str, str]
|
Custom properties to be added to the snapshot summary |
EMPTY_DICT
|
Source code in pyiceberg/table/__init__.py
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
delete(delete_filter, snapshot_properties=EMPTY_DICT)
¶
Shorthand for deleting record from a table.
An deletee may produce zero or more snapshots based on the operation:
- DELETE: In case existing Parquet files can be dropped completely.
- REPLACE: In case existing Parquet files need to be rewritten
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delete_filter
|
Union[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
|
Source code in pyiceberg/table/__init__.py
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 |
|
overwrite(df, overwrite_filter=ALWAYS_TRUE, snapshot_properties=EMPTY_DICT)
¶
Shorthand for adding a table overwrite with a PyArrow table to the transaction.
An overwrite may produce zero or more snapshots based on the operation:
- DELETE: In case existing Parquet files can be dropped completely.
- REPLACE: In case existing Parquet files need to be rewritten.
- APPEND: In case new data is being inserted into the table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
Table
|
The Arrow dataframe that will be used to overwrite the table |
required |
overwrite_filter
|
Union[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
|
Source code in pyiceberg/table/__init__.py
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)
¶
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_spec()
¶
Create a new UpdateSpec to update the partitioning of the table.
Returns:
Type | Description |
---|---|
UpdateSpec
|
A new UpdateSpec. |
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
WriteTask
dataclass
¶
Task with the parameters for writing a DataFile.