API Reference¶
Auto-generated documentation from source code docstrings.
Configuration¶
poor_man_lakehouse.config.Settings
¶
Bases: BaseSettings
Settings class for application settings and secrets management.
Docs: https://docs.pydantic.dev/latest/concepts/pydantic_settings/
poor_man_lakehouse.config.get_settings()
cached
¶
Generate and get the settings.
Returns:
| Type | Description |
|---|---|
Settings
|
Configured Settings instance. |
Raises:
| Type | Description |
|---|---|
SettingsError
|
If settings initialization fails. |
Source code in src/poor_man_lakehouse/config.py
poor_man_lakehouse.config.reload_settings()
¶
Catalog Factory¶
poor_man_lakehouse.catalog.get_catalog(catalog_type=None)
¶
Create a PyIceberg Catalog for the specified or configured catalog type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog_type
|
LakehouseCatalogType | None
|
Catalog backend to use. Defaults to settings.CATALOG. |
None
|
Returns:
| Type | Description |
|---|---|
Catalog
|
A configured PyIceberg Catalog instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the catalog type is not supported. |
Source code in src/poor_man_lakehouse/catalog.py
poor_man_lakehouse.catalog.LakehouseCatalogType = Literal['nessie', 'lakekeeper', 'postgres', 'glue']
module-attribute
¶
Connectors¶
LakehouseConnection¶
poor_man_lakehouse.lakehouse.LakehouseConnection
¶
Unified connection manager for Iceberg table access.
Provides catalog browsing, native Polars/Arrow scans, DuckDB engine access, and Ibis multi-engine wrappers. All operations go through a single PyIceberg catalog instance created by get_catalog().
Supports catalogs: lakekeeper, nessie, postgres, glue.
Example
conn = LakehouseConnection() conn.list_namespaces() ['default', 'staging'] lf = conn.scan_polars( ... "default", ... "users", ... ) duck = conn.duckdb_connection
Source code in src/poor_man_lakehouse/lakehouse.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 | |
duckdb_connection
cached
property
¶
Lazily initialize DuckDB Ibis connection with Iceberg catalog attached.
__init__(catalog_type=None)
¶
Initialize the connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog_type
|
LakehouseCatalogType | None
|
Catalog backend to use. Defaults to settings.CATALOG. |
None
|
Source code in src/poor_man_lakehouse/lakehouse.py
list_namespaces()
¶
list_tables(namespace)
¶
List all tables in a namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace to list tables from. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of table names. |
Source code in src/poor_man_lakehouse/lakehouse.py
load_table(namespace, table_name)
¶
Load an Iceberg table object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace containing the table. |
required |
table_name
|
str
|
The table name. |
required |
Returns:
| Type | Description |
|---|---|
Table
|
PyIceberg Table object with full metadata access. |
Source code in src/poor_man_lakehouse/lakehouse.py
table_schema(namespace, table_name)
¶
Get the schema of an Iceberg table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace containing the table. |
required |
table_name
|
str
|
The table name. |
required |
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of dicts with field_id, name, type, and required for each column. |
Source code in src/poor_man_lakehouse/lakehouse.py
snapshot_history(namespace, table_name)
¶
Get the snapshot history of a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace containing the table. |
required |
table_name
|
str
|
The table name. |
required |
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of snapshot dicts with snapshot_id, timestamp_ms, and summary. |
Source code in src/poor_man_lakehouse/lakehouse.py
scan_polars(namespace, table_name)
¶
Scan an Iceberg table and return a Polars LazyFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace containing the table. |
required |
table_name
|
str
|
The table name. |
required |
Returns:
| Type | Description |
|---|---|
LazyFrame
|
Polars LazyFrame for lazy evaluation. |
Source code in src/poor_man_lakehouse/lakehouse.py
scan_arrow(namespace, table_name)
¶
Scan an Iceberg table and return a PyArrow Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace containing the table. |
required |
table_name
|
str
|
The table name. |
required |
Returns:
| Type | Description |
|---|---|
Table
|
PyArrow Table. |
Source code in src/poor_man_lakehouse/lakehouse.py
ibis_duckdb()
¶
Get the DuckDB Ibis backend with catalog attached.
Returns:
| Type | Description |
|---|---|
Backend
|
DuckDB Ibis backend connection. |
ibis_polars(namespace, table_name)
¶
Get a Polars Ibis backend with a table registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace containing the table. |
required |
table_name
|
str
|
The table name. |
required |
Returns:
| Type | Description |
|---|---|
Backend
|
Polars Ibis backend with the table registered. |
Source code in src/poor_man_lakehouse/lakehouse.py
ibis_pyspark()
¶
Get the PySpark Ibis backend.
Returns:
| Type | Description |
|---|---|
Backend
|
PySpark Ibis backend connection. |
Source code in src/poor_man_lakehouse/lakehouse.py
sql(query, engine='duckdb')
¶
Execute a SQL query using the specified engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The SQL query string. |
required |
engine
|
SQLEngine
|
The engine to use ("duckdb" or "pyspark"). |
'duckdb'
|
Returns:
| Type | Description |
|---|---|
Table
|
Ibis table expression with query results. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If engine is not supported for SQL. |
Source code in src/poor_man_lakehouse/lakehouse.py
write_table(namespace, table_name, *, data=None, query=None, mode='append')
¶
Write data to an Iceberg table via DuckDB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace name. |
required |
table_name
|
str
|
The table name. |
required |
data
|
Table | None
|
Ibis table expression to write. Mutually exclusive with query. |
None
|
query
|
str | None
|
SQL query whose results to write. Mutually exclusive with data. |
None
|
mode
|
WriteMode
|
Write mode — "append" or "overwrite". |
'append'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If mode is invalid or neither data nor query is provided. |
Source code in src/poor_man_lakehouse/lakehouse.py
create_table(namespace, table_name, schema_sql)
¶
Create an Iceberg table via DuckDB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
The namespace name. |
required |
table_name
|
str
|
The table name. |
required |
schema_sql
|
str
|
Column definitions, e.g. "id INTEGER, name VARCHAR". |
required |
Source code in src/poor_man_lakehouse/lakehouse.py
close()
¶
Close all active connections and clear cached properties.
Spark¶
SparkBuilder¶
poor_man_lakehouse.spark_connector.builder.SparkBuilder
¶
Bases: ABC
Abstract base class for Spark session builders.
Provides common configuration for S3/Minio access and shared packages. Subclasses only need to implement catalog-specific configuration.
catalog_name
property
¶
Return the catalog name for this builder.
Default implementation uses settings.CATALOG_NAME. Subclasses can override for custom catalog names.
get_spark_session()
¶
Build and return a configured Spark session with Iceberg and Delta support.
Returns:
| Type | Description |
|---|---|
SparkSession
|
A configured SparkSession instance with both Iceberg catalog access |
SparkSession
|
and Delta Lake path-based access enabled. |
poor_man_lakehouse.spark_connector.builder.CatalogType
¶
poor_man_lakehouse.spark_connector.builder.get_spark_builder(catalog_type)
¶
Get the appropriate Spark builder for the given catalog type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog_type
|
CatalogType | str
|
The catalog type (enum or string). |
required |
Returns:
| Type | Description |
|---|---|
SparkBuilder
|
An instance of the appropriate SparkBuilder subclass. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the catalog type is not supported. |
Source code in src/poor_man_lakehouse/spark_connector/builder.py
poor_man_lakehouse.spark_connector.builder.retrieve_current_spark_session()
¶
Retrieve a Spark session configured for the current catalog setting.
Uses the CATALOG setting from configuration to determine which catalog implementation to use.
Returns:
| Type | Description |
|---|---|
SparkSession
|
A configured SparkSession instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the configured catalog is not supported. |