Skip to content

Commit a02c0bf

Browse files
authored
docs: Add missing methods for table and namespace manipulation (#2942)
<!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change We have some methods for working with tables + namespaces on catalogs that we haven't properly documented. This documentation is super helpful for new users to understand what they can use PyIceberg for. It's also helpful for our LLM...friends? to help understand the project. ## Are these changes tested? Docs only. ## Are there any user-facing changes? Docs only. <!-- In the case of user-facing changes, please add the changelog label. -->
1 parent fe6b6fc commit a02c0bf

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

mkdocs/docs/api.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ ns = catalog.list_namespaces()
8282
assert ns == [("docs_example",)]
8383
```
8484

85+
Next, update the namespace properties.
86+
87+
```python
88+
89+
# Load namespace properties
90+
properties = catalog.load_namespace_properties("docs_example")
91+
92+
# Update namespace properties with additions and removals.
93+
catalog.update_namespace_properties("docs_example", removals={"remove-meee!"}, updates={"owner": "iceberg"})
94+
```
95+
96+
Finally, drop the namespace (if you want!)
97+
98+
```python
99+
# Drop a namespace
100+
catalog.drop_namespace("docs_example")
101+
```
102+
85103
## Create a table
86104

87105
To create a table from a catalog:
@@ -167,6 +185,17 @@ with catalog.create_table_transaction(identifier="docs_example.bids", schema=sch
167185
txn.set_properties(test_a="test_aa", test_b="test_b", test_c="test_c")
168186
```
169187

188+
## Register a table
189+
190+
To register a table using existing metadata:
191+
192+
```python
193+
catalog.register_table(
194+
identifier="docs_example.bids",
195+
metadata_location="s3://warehouse/path/to/metadata.json"
196+
)
197+
```
198+
170199
## Load a table
171200

172201
There are two ways of reading an Iceberg table; through a catalog, and by pointing at the Iceberg metadata directly. Reading through a catalog is preferred, and directly pointing at the metadata is read-only.
@@ -216,6 +245,31 @@ catalog.table_exists("docs_example.bids")
216245

217246
Returns `True` if the table already exists.
218247

248+
## Rename a table
249+
250+
To rename a table:
251+
252+
```python
253+
catalog.rename_table(
254+
from_identifier="docs_example.bids",
255+
to_identifier="docs_example.bids_backup"
256+
)
257+
```
258+
259+
## Drop a table
260+
261+
To drop a table:
262+
263+
```python
264+
catalog.drop_table("docs_example.bids")
265+
```
266+
267+
To drop a table and purge all data and metadata files:
268+
269+
```python
270+
catalog.purge_table("docs_example.bids")
271+
```
272+
219273
## Write to a table
220274

221275
Reading and writing is being done using [Apache Arrow](https://arrow.apache.org/). Arrow is an in-memory columnar format for fast data interchange and in-memory analytics. Let's consider the following Arrow Table:

0 commit comments

Comments
 (0)