catalog
Catalog
¶
Bases: ABC
Base Catalog for table operations like - create, drop, load, list and others.
The catalog table APIs accept a table identifier, which is fully classified table name. The identifier can be a string or tuple of strings. If the identifier is a string, it is split into a tuple on '.'. If it is a tuple, it is used as-is.
The catalog namespace APIs follow a similar convention wherein they also accept a namespace identifier that can be a string or tuple of strings.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the catalog. |
properties |
Properties
|
Catalog properties. |
Source code in pyiceberg/catalog/__init__.py
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 |
|
__repr__()
¶
commit_table(table, requirements, updates)
abstractmethod
¶
Commit updates to a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table
|
Table
|
The table to be updated. |
required |
requirements
|
Tuple[TableRequirement, ...]
|
(Tuple[TableRequirement, ...]): Table requirements. |
required |
updates
|
Tuple[TableUpdate, ...]
|
(Tuple[TableUpdate, ...]): Table updates. |
required |
Returns:
Name | Type | Description |
---|---|---|
CommitTableResponse |
CommitTableResponse
|
The updated metadata. |
Raises:
Type | Description |
---|---|
NoSuchTableError
|
If a table with the given identifier does not exist. |
CommitFailedException
|
Requirement not met, or a conflict with a concurrent commit. |
CommitStateUnknownException
|
Failed due to an internal exception on the side of the catalog. |
Source code in pyiceberg/catalog/__init__.py
create_namespace(namespace, properties=EMPTY_DICT)
abstractmethod
¶
Create a namespace in the catalog.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier. |
required |
properties
|
Properties
|
A string dictionary of properties for the given namespace. |
EMPTY_DICT
|
Raises:
Type | Description |
---|---|
NamespaceAlreadyExistsError
|
If a namespace with the given name already exists. |
Source code in pyiceberg/catalog/__init__.py
create_namespace_if_not_exists(namespace, properties=EMPTY_DICT)
¶
Create a namespace if it does not exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier. |
required |
properties
|
Properties
|
A string dictionary of properties for the given namespace. |
EMPTY_DICT
|
Source code in pyiceberg/catalog/__init__.py
create_table(identifier, schema, location=None, partition_spec=UNPARTITIONED_PARTITION_SPEC, sort_order=UNSORTED_SORT_ORDER, properties=EMPTY_DICT)
abstractmethod
¶
Create a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
schema
|
Schema
|
Table's schema. |
required |
location
|
str | None
|
Location for the table. Optional Argument. |
None
|
partition_spec
|
PartitionSpec
|
PartitionSpec for the table. |
UNPARTITIONED_PARTITION_SPEC
|
sort_order
|
SortOrder
|
SortOrder for the table. |
UNSORTED_SORT_ORDER
|
properties
|
Properties
|
Table properties that can be a string based dictionary. |
EMPTY_DICT
|
Returns:
Name | Type | Description |
---|---|---|
Table |
Table
|
the created table instance. |
Raises:
Type | Description |
---|---|
TableAlreadyExistsError
|
If a table with the name already exists. |
Source code in pyiceberg/catalog/__init__.py
create_table_if_not_exists(identifier, schema, location=None, partition_spec=UNPARTITIONED_PARTITION_SPEC, sort_order=UNSORTED_SORT_ORDER, properties=EMPTY_DICT)
¶
Create a table if it does not exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
schema
|
Schema
|
Table's schema. |
required |
location
|
str | None
|
Location for the table. Optional Argument. |
None
|
partition_spec
|
PartitionSpec
|
PartitionSpec for the table. |
UNPARTITIONED_PARTITION_SPEC
|
sort_order
|
SortOrder
|
SortOrder for the table. |
UNSORTED_SORT_ORDER
|
properties
|
Properties
|
Table properties that can be a string based dictionary. |
EMPTY_DICT
|
Returns:
Name | Type | Description |
---|---|---|
Table |
Table
|
the created table instance if the table does not exist, else the existing |
Table
|
table instance. |
Source code in pyiceberg/catalog/__init__.py
create_table_transaction(identifier, schema, location=None, partition_spec=UNPARTITIONED_PARTITION_SPEC, sort_order=UNSORTED_SORT_ORDER, properties=EMPTY_DICT)
abstractmethod
¶
Create a CreateTableTransaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
schema
|
Schema
|
Table's schema. |
required |
location
|
str | None
|
Location for the table. Optional Argument. |
None
|
partition_spec
|
PartitionSpec
|
PartitionSpec for the table. |
UNPARTITIONED_PARTITION_SPEC
|
sort_order
|
SortOrder
|
SortOrder for the table. |
UNSORTED_SORT_ORDER
|
properties
|
Properties
|
Table properties that can be a string based dictionary. |
EMPTY_DICT
|
Returns:
Name | Type | Description |
---|---|---|
CreateTableTransaction |
CreateTableTransaction
|
createTableTransaction instance. |
Source code in pyiceberg/catalog/__init__.py
drop_namespace(namespace)
abstractmethod
¶
Drop a namespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier. |
required |
Raises:
Type | Description |
---|---|
NoSuchNamespaceError
|
If a namespace with the given name does not exist. |
NamespaceNotEmptyError
|
If the namespace is not empty. |
Source code in pyiceberg/catalog/__init__.py
drop_table(identifier)
abstractmethod
¶
Drop a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
Raises:
Type | Description |
---|---|
NoSuchTableError
|
If a table with the name does not exist. |
Source code in pyiceberg/catalog/__init__.py
drop_view(identifier)
abstractmethod
¶
Drop a view.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
View identifier. |
required |
Raises:
Type | Description |
---|---|
NoSuchViewError
|
If a view with the given name does not exist. |
Source code in pyiceberg/catalog/__init__.py
identifier_to_tuple(identifier)
staticmethod
¶
Parse an identifier to a tuple.
If the identifier is a string, it is split into a tuple on '.'. If it is a tuple, it is used as-is.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
an identifier, either a string or tuple of strings. |
required |
Returns:
Name | Type | Description |
---|---|---|
Identifier |
Identifier
|
a tuple of strings. |
Source code in pyiceberg/catalog/__init__.py
identifier_to_tuple_without_catalog(identifier)
¶
Convert an identifier to a tuple and drop this catalog's name from the first element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
Returns:
Name | Type | Description |
---|---|---|
Identifier |
Identifier
|
a tuple of strings with this catalog's name removed |
Source code in pyiceberg/catalog/__init__.py
list_namespaces(namespace=())
abstractmethod
¶
List namespaces from the given namespace. If not given, list top-level namespaces from the catalog.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier to search. |
()
|
Returns:
Type | Description |
---|---|
List[Identifier]
|
List[Identifier]: a List of namespace identifiers. |
Raises:
Type | Description |
---|---|
NoSuchNamespaceError
|
If a namespace with the given name does not exist. |
Source code in pyiceberg/catalog/__init__.py
list_tables(namespace)
abstractmethod
¶
List tables under the given namespace in the catalog.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier to search. |
required |
Returns:
Type | Description |
---|---|
List[Identifier]
|
List[Identifier]: list of table identifiers. |
Raises:
Type | Description |
---|---|
NoSuchNamespaceError
|
If a namespace with the given name does not exist. |
Source code in pyiceberg/catalog/__init__.py
list_views(namespace)
abstractmethod
¶
List views under the given namespace in the catalog.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier to search. |
required |
Returns:
Type | Description |
---|---|
List[Identifier]
|
List[Identifier]: list of table identifiers. |
Raises:
Type | Description |
---|---|
NoSuchNamespaceError
|
If a namespace with the given name does not exist. |
Source code in pyiceberg/catalog/__init__.py
load_namespace_properties(namespace)
abstractmethod
¶
Get properties for a namespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier. |
required |
Returns:
Name | Type | Description |
---|---|---|
Properties |
Properties
|
Properties for the given namespace. |
Raises:
Type | Description |
---|---|
NoSuchNamespaceError
|
If a namespace with the given name does not exist. |
Source code in pyiceberg/catalog/__init__.py
load_table(identifier)
abstractmethod
¶
Load the table's metadata and returns the table instance.
You can also use this method to check for table existence using 'try catalog.table() except NoSuchTableError'. Note: This method doesn't scan data stored in the table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
Returns:
Name | Type | Description |
---|---|---|
Table |
Table
|
the table instance with its metadata. |
Raises:
Type | Description |
---|---|
NoSuchTableError
|
If a table with the name does not exist. |
Source code in pyiceberg/catalog/__init__.py
namespace_from(identifier)
staticmethod
¶
Extract table namespace from a table identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
Union[str, Identifier]
|
a table identifier. |
required |
Returns:
Name | Type | Description |
---|---|---|
Identifier |
Identifier
|
Namespace identifier. |
Source code in pyiceberg/catalog/__init__.py
namespace_to_string(identifier, err=ValueError)
staticmethod
¶
Transform a namespace identifier into a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
Union[str, Identifier]
|
a namespace identifier. |
required |
err
|
Union[Type[ValueError], Type[NoSuchNamespaceError]]
|
the error type to raise when identifier is empty. |
ValueError
|
Returns:
Name | Type | Description |
---|---|---|
Identifier |
str
|
Namespace identifier. |
Source code in pyiceberg/catalog/__init__.py
purge_table(identifier)
abstractmethod
¶
Drop a table and purge all data and metadata files.
Note: This method only logs warning rather than raise exception when encountering file deletion failure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
Raises:
Type | Description |
---|---|
NoSuchTableError
|
If a table with the name does not exist, or the identifier is invalid. |
Source code in pyiceberg/catalog/__init__.py
register_table(identifier, metadata_location)
abstractmethod
¶
Register a new table using existing metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
Union[str, Identifier]
|
Table identifier for the table |
required |
metadata_location
|
str
|
The location to the metadata |
required |
Returns:
Name | Type | Description |
---|---|---|
Table |
Table
|
The newly registered table |
Raises:
Type | Description |
---|---|
TableAlreadyExistsError
|
If the table already exists |
Source code in pyiceberg/catalog/__init__.py
rename_table(from_identifier, to_identifier)
abstractmethod
¶
Rename a fully classified table name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_identifier
|
str | Identifier
|
Existing table identifier. |
required |
to_identifier
|
str | Identifier
|
New table identifier. |
required |
Returns:
Name | Type | Description |
---|---|---|
Table |
Table
|
the updated table instance with its metadata. |
Raises:
Type | Description |
---|---|
NoSuchTableError
|
If a table with the name does not exist. |
Source code in pyiceberg/catalog/__init__.py
table_exists(identifier)
abstractmethod
¶
Check if a table exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
Table identifier. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the table exists, False otherwise. |
Source code in pyiceberg/catalog/__init__.py
table_name_from(identifier)
staticmethod
¶
Extract table name from a table identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | Identifier
|
a table identifier. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Table name. |
Source code in pyiceberg/catalog/__init__.py
update_namespace_properties(namespace, removals=None, updates=EMPTY_DICT)
abstractmethod
¶
Remove provided property keys and updates properties for a namespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str | Identifier
|
Namespace identifier. |
required |
removals
|
Set[str]
|
Set of property keys that need to be removed. Optional Argument. |
None
|
updates
|
Properties
|
Properties to be updated for the given namespace. |
EMPTY_DICT
|
Raises:
Type | Description |
---|---|
NoSuchNamespaceError
|
If a namespace with the given name does not exist. |
ValueError
|
If removals and updates have overlapping keys. |
Source code in pyiceberg/catalog/__init__.py
MetastoreCatalog
¶
Bases: Catalog
, ABC
Source code in pyiceberg/catalog/__init__.py
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 |
|
delete_data_files(io, manifests_to_delete)
¶
Delete data files linked to given manifests.
Log warnings if failing to delete any file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
io
|
FileIO
|
The FileIO used to delete the object. |
required |
manifests_to_delete
|
List[ManifestFile]
|
A list of manifest contains paths of data files to be deleted. |
required |
Source code in pyiceberg/catalog/__init__.py
delete_files(io, files_to_delete, file_type)
¶
Delete files.
Log warnings if failing to delete any file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
io
|
FileIO
|
The FileIO used to delete the object. |
required |
files_to_delete
|
Set[str]
|
A set of file paths to be deleted. |
required |
file_type
|
str
|
The type of the file. |
required |
Source code in pyiceberg/catalog/__init__.py
infer_catalog_type(name, catalog_properties)
¶
Try to infer the type based on the dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the catalog. |
required |
catalog_properties
|
RecursiveDict
|
Catalog properties. |
required |
Returns:
Type | Description |
---|---|
Optional[CatalogType]
|
The inferred type based on the provided properties. |
Raises:
Type | Description |
---|---|
ValueError
|
Raises a ValueError in case properties are missing, or the wrong type. |
Source code in pyiceberg/catalog/__init__.py
load_catalog(name=None, **properties)
¶
Load the catalog based on the properties.
Will look up the properties from the config, based on the name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
The name of the catalog. |
None
|
properties
|
Optional[str]
|
The properties that are used next to the configuration. |
{}
|
Returns:
Type | Description |
---|---|
Catalog
|
An initialized Catalog. |
Raises:
Type | Description |
---|---|
ValueError
|
Raises a ValueError in case properties are missing or malformed, or if it could not determine the catalog based on the properties. |