Skip to content

Commit e1f786f

Browse files
author
Jack Ye
committed
use sql catalog for test and add doc
1 parent b251226 commit e1f786f

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

mkdocs/docs/configuration.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ For the FileIO there are several configuration options available:
139139

140140
## Catalogs
141141

142-
PyIceberg currently has native support for REST, SQL, Hive, Glue and DynamoDB.
142+
PyIceberg currently has native catalog type support for REST, SQL, Hive, Glue and DynamoDB.
143+
You can also set the catalog implementation explicitly:
144+
145+
| Key | Example | Description |
146+
| --------------- | ---------------------------- | ------------------------------------------------------------------------------------------------ |
147+
| type | rest | Type of catalog, one of `rest`, `sql`, `hive`, `glue`, `dymamodb`. Default to `rest` |
148+
| py-catalog-impl | mypackage.mymodule.MyCatalog | Sets the catalog explicitly to an implementation, and will fail explicitly if it can't be loaded |
143149

144150
There are three ways to pass in configuration:
145151

@@ -379,6 +385,18 @@ catalog:
379385

380386
<!-- prettier-ignore-end -->
381387

388+
### Custom Catalog Implementations
389+
390+
If you want to load any custom catalog implementation, you can set catalog configurations like the following:
391+
392+
```yaml
393+
catalog:
394+
default:
395+
py-catalog-impl: mypackage.mymodule.MyCatalog
396+
custom-key1: value1
397+
custom-key2: value2
398+
```
399+
382400
## Unified AWS Credentials
383401

384402
You can explicitly set the AWS credentials for both Glue/DynamoDB Catalog and S3 FileIO by configuring `client.*` properties. For example:

tests/catalog/test_glue.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import pytest
2323
from moto import mock_aws
2424

25-
from pyiceberg.catalog import load_catalog
2625
from pyiceberg.catalog.glue import GlueCatalog
2726
from pyiceberg.exceptions import (
2827
NamespaceAlreadyExistsError,
@@ -47,23 +46,6 @@
4746
)
4847

4948

50-
@mock_aws
51-
def test_load_catalog_from_impl() -> None:
52-
assert isinstance(
53-
load_catalog(
54-
"catalog",
55-
**{
56-
"py-catalog-impl": "pyiceberg.catalog.glue.GlueCatalog",
57-
"glue.region_name": "us-east-1",
58-
"glue.aws_access_key_id": "access-key",
59-
"glue.aws_secret_access_key": "secret-key",
60-
"glue.aws_session_token": "session-token",
61-
},
62-
),
63-
GlueCatalog,
64-
)
65-
66-
6749
@mock_aws
6850
def test_create_table_with_database_location(
6951
_glue: boto3.client,

tests/catalog/test_sql.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
from pyiceberg.catalog import (
2929
Catalog,
30+
load_catalog,
3031
)
3132
from pyiceberg.catalog.sql import DEFAULT_ECHO_VALUE, DEFAULT_POOL_PRE_PING_VALUE, SqlCatalog
3233
from pyiceberg.exceptions import (
@@ -210,6 +211,17 @@ def test_creation_with_pool_pre_ping_parameter(catalog_name: str, warehouse: Pat
210211
)
211212

212213

214+
def test_creation_from_impl(catalog_name: str, warehouse: Path) -> None:
215+
assert isinstance(
216+
load_catalog(
217+
catalog_name,
218+
uri=f"sqlite:////{warehouse}/sql-catalog.db",
219+
warehouse=f"file://{warehouse}",
220+
),
221+
SqlCatalog,
222+
)
223+
224+
213225
@pytest.mark.parametrize(
214226
"catalog",
215227
[

0 commit comments

Comments
 (0)