Skip to content

Commit 7f274a0

Browse files
committed
apply suggestions
1 parent cf2dbfa commit 7f274a0

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

mkdocs/docs/configuration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,23 @@ catalog:
388388
| echo | true | false | SQLAlchemy engine [echo param](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.echo) to log all statements to the default log handler |
389389
| pool_pre_ping | true | false | SQLAlchemy engine [pool_pre_ping param](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.pool_pre_ping) to test connections for liveness upon each checkout |
390390

391+
### In Memory Catalog
392+
393+
The in-memory catalog is built on top of `SqlCatalog` and uses SQLite in-memory database for its backend.
394+
395+
It is useful for test, demo, and playground but not in production as it does not support concurrent access.
396+
397+
```yaml
398+
catalog:
399+
default:
400+
type: in-memory
401+
warehouse: /tmp/pyiceberg/warehouse
402+
```
403+
404+
| Key | Example | Default | Description |
405+
| --------- |--------------------------|-------------------------------|----------------------------------------------------------------------|
406+
| warehouse | /tmp/pyiceberg/warehouse | file:///tmp/iceberg/warehouse | The directory where the in-memory catalog will store its data files. |
407+
391408
### Hive Catalog
392409

393410
```yaml

pyiceberg/catalog/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class CatalogType(Enum):
116116
GLUE = "glue"
117117
DYNAMODB = "dynamodb"
118118
SQL = "sql"
119+
IN_MEMORY = "in-memory"
119120

120121

121122
def load_rest(name: str, conf: Properties) -> Catalog:
@@ -162,12 +163,22 @@ def load_sql(name: str, conf: Properties) -> Catalog:
162163
) from exc
163164

164165

166+
def load_in_memory(name: str, conf: Properties) -> Catalog:
167+
try:
168+
from pyiceberg.catalog.memory import InMemoryCatalog
169+
170+
return InMemoryCatalog(name, **conf)
171+
except ImportError as exc:
172+
raise NotInstalledError("SQLAlchemy support not installed: pip install 'pyiceberg[sql-sqlite]'") from exc
173+
174+
165175
AVAILABLE_CATALOGS: dict[CatalogType, Callable[[str, Properties], Catalog]] = {
166176
CatalogType.REST: load_rest,
167177
CatalogType.HIVE: load_hive,
168178
CatalogType.GLUE: load_glue,
169179
CatalogType.DYNAMODB: load_dynamodb,
170180
CatalogType.SQL: load_sql,
181+
CatalogType.IN_MEMORY: load_in_memory,
171182
}
172183

173184

pyiceberg/catalog/memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class InMemoryCatalog(SqlCatalog):
2222
"""
2323
An in-memory catalog implementation that uses SqlCatalog with SQLite in-memory database.
2424
25-
This is useful for test, demo, and playground but not in production as data is not persisted.
25+
This is useful for test, demo, and playground but not in production as it does not support concurrent access.
2626
"""
2727

28-
def __init__(self, name: str, warehouse: str = "file:///tmp/warehouse", **kwargs: str) -> None:
28+
def __init__(self, name: str, warehouse: str = "file:///tmp/iceberg/warehouse", **kwargs: str) -> None:
2929
self._warehouse_location = warehouse
3030
if "uri" not in kwargs:
3131
kwargs["uri"] = "sqlite:///:memory:"

tests/cli/test_console.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,9 @@ def test_json_properties_get_table_does_not_exist(catalog: InMemoryCatalog) -> N
829829
# pylint: disable=unused-argument
830830

831831
runner = CliRunner()
832-
result = runner.invoke(run, ["--output=json", "properties", "get", "table", "doesnotexist"])
832+
result = runner.invoke(run, ["--output=json", "properties", "get", "table", "default.doesnotexist"])
833833
assert result.exit_code == 1
834-
assert result.output == """{"type": "ValueError", "message": "Empty namespace identifier"}\n"""
834+
assert result.output == """{"type": "NoSuchTableError", "message": "Table does not exist: default.doesnotexist"}\n"""
835835

836836

837837
def test_json_properties_get_namespace(catalog: InMemoryCatalog, namespace_properties: Properties) -> None:

0 commit comments

Comments
 (0)