dataenginex.lakehouse¶
Storage backends, data catalog, and partitioning strategies.
dataenginex.lakehouse
¶
Storage backends, data catalog, and partitioning.
Public API::
from dataenginex.lakehouse import (
# Storage backends
StorageBackend,
ParquetStorage, JsonStorage, S3Storage, GCSStorage,
get_storage,
# Catalog
CatalogEntry, DataCatalog,
# Partitioning
PartitionStrategy, DatePartitioner, HashPartitioner,
)
StorageBackend
¶
Bases: ABC
Abstract storage backend interface.
All lakehouse storage implementations must subclass this and provide
concrete write, read, delete, list_objects, and
exists methods. The interface accepts a StorageFormat hint
so backends can choose serialisation.
Built-in implementations
LocalParquetStorage— local Parquet files (this module)BigQueryStorage— Google BigQuery tables (this module)JsonStorage— JSON files (dataenginex.lakehouse.storage)ParquetStorage— pyarrow-backed Parquet (dataenginex.lakehouse.storage)S3Storage— AWS S3 object storage (dataenginex.lakehouse.storage)GCSStorage— Google Cloud Storage (dataenginex.lakehouse.storage)
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
write(data, path, format)
abstractmethod
¶
Write data to path in the given format.
Returns True on success, False on failure.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
read(path, format)
abstractmethod
¶
delete(path)
abstractmethod
¶
list_objects(prefix='')
abstractmethod
¶
List object paths under prefix.
Returns a list of relative paths. Empty list on failure or when no objects match.
Source code in packages/dataenginex/src/dataenginex/core/medallion_architecture.py
CatalogEntry
dataclass
¶
Metadata about a single dataset in the lakehouse.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique dataset name. |
layer |
str
|
Medallion layer ( |
format |
str
|
Storage format ( |
location |
str
|
File path or table reference. |
record_count |
int
|
Approximate number of records. |
schema_fields |
list[str]
|
List of column/field names. |
description |
str
|
Human-readable dataset description. |
owner |
str
|
Team or user responsible for the dataset. |
tags |
list[str]
|
Arbitrary labels for discovery. |
created_at |
datetime
|
When the dataset was first registered. |
updated_at |
datetime
|
When the entry was last updated. |
metadata |
dict[str, Any]
|
Free-form context dict. |
version |
int
|
Auto-incremented version counter. |
Source code in packages/dataenginex/src/dataenginex/lakehouse/catalog.py
to_dict()
¶
Serialize the catalog entry to a plain dictionary.
Source code in packages/dataenginex/src/dataenginex/lakehouse/catalog.py
DataCatalog
¶
In-process data catalog backed by an optional JSON file.
Parameters¶
persist_path: When set, catalog entries are persisted to this JSON file.
Source code in packages/dataenginex/src/dataenginex/lakehouse/catalog.py
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 | |
register(entry)
¶
Register or update a dataset entry.
Source code in packages/dataenginex/src/dataenginex/lakehouse/catalog.py
get(name)
¶
search(*, layer=None, tags=None, owner=None, name_contains=None)
¶
Search entries by criteria.
Source code in packages/dataenginex/src/dataenginex/lakehouse/catalog.py
list_all()
¶
delete(name)
¶
summary()
¶
High-level catalog statistics.
Source code in packages/dataenginex/src/dataenginex/lakehouse/catalog.py
DatePartitioner
¶
Bases: PartitionStrategy
Partition by a date field using year=…/month=…/day=… layout.
Parameters¶
date_field:
Name of the record field containing a date/datetime value.
granularity:
"day" (default), "month", or "year".
Source code in packages/dataenginex/src/dataenginex/lakehouse/partitioning.py
partition_key(record)
¶
Return a year=.../month=.../day=... key for record.
Source code in packages/dataenginex/src/dataenginex/lakehouse/partitioning.py
partition_path(record, base='')
¶
Return base joined with the date partition key.
HashPartitioner
¶
Bases: PartitionStrategy
Partition by a hash of one or more fields, distributing across n_buckets.
Parameters¶
fields: Record fields whose values are hashed. n_buckets: Number of hash buckets (directories).
Source code in packages/dataenginex/src/dataenginex/lakehouse/partitioning.py
partition_key(record)
¶
Return a bucket=NNNN key based on hashed field values.
Source code in packages/dataenginex/src/dataenginex/lakehouse/partitioning.py
partition_path(record, base='')
¶
Return base joined with the hash-bucket partition key.
Source code in packages/dataenginex/src/dataenginex/lakehouse/partitioning.py
PartitionStrategy
¶
Bases: ABC
Base class for partitioning strategies.
Source code in packages/dataenginex/src/dataenginex/lakehouse/partitioning.py
GCSStorage
¶
Bases: StorageBackend
Google Cloud Storage backend.
Reads/writes JSON-serialised records to a GCS bucket. Requires
google-cloud-storage at runtime.
Parameters¶
bucket:
GCS bucket name.
prefix:
Key prefix for all objects (default "").
project:
GCP project ID (optional, uses ADC default).
api_endpoint:
Custom API endpoint for GCS-compatible services (e.g.
fake-gcs-server). When None, the default Google
endpoint is used.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
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 | |
write(data, path, format=StorageFormat.PARQUET)
¶
Write JSON-serialised data to GCS.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
read(path, format=StorageFormat.PARQUET)
¶
Read JSON data from GCS.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
delete(path)
¶
Delete object from GCS.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
list_objects(prefix='')
¶
List GCS objects under prefix.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
exists(path)
¶
Return True if path exists in GCS.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
JsonStorage
¶
Bases: StorageBackend
Simple JSON-file storage for development and testing.
Each write call serialises data (list of dicts) as a JSON array.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
write(data, path, format=StorageFormat.PARQUET)
¶
Serialize data as JSON and write to path.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
read(path, format=StorageFormat.PARQUET)
¶
Read and deserialize a JSON file at path.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
delete(path)
¶
Delete the JSON file at path if it exists.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
list_objects(prefix='')
¶
List JSON entries under prefix.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
ParquetStorage
¶
Bases: StorageBackend
Parquet file storage backed by pyarrow.
Falls back to JsonStorage when pyarrow is not installed.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
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 | |
write(data, path, format=StorageFormat.PARQUET)
¶
Write data as a Parquet file at path.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
read(path, format=StorageFormat.PARQUET)
¶
Read a Parquet file at path and return records.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
delete(path)
¶
Delete the Parquet file at path if it exists.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
list_objects(prefix='')
¶
List Parquet entries under prefix.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
exists(path)
¶
Return True if path has a corresponding Parquet file.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
S3Storage
¶
Bases: StorageBackend
AWS S3 object storage backend.
Reads/writes JSON-serialised records to an S3 bucket. Requires
boto3 at runtime.
Parameters¶
bucket:
S3 bucket name.
prefix:
Key prefix for all objects (default "").
region:
AWS region (default "us-east-1").
endpoint_url:
Custom endpoint for S3-compatible services (e.g. LocalStack).
When None, the default AWS endpoint is used.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
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 | |
write(data, path, format=StorageFormat.PARQUET)
¶
Write JSON-serialised data to S3.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
read(path, format=StorageFormat.PARQUET)
¶
Read JSON data from S3.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
delete(path)
¶
Delete object from S3.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
list_objects(prefix='')
¶
List S3 objects under prefix.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
exists(path)
¶
Return True if path exists in S3.
Source code in packages/dataenginex/src/dataenginex/lakehouse/storage.py
get_storage(uri, **kwargs)
¶
Create a :class:StorageBackend from a URI scheme.
Supported schemes:
file://(or no scheme) → :class:JsonStorages3://bucket/prefix→ :class:S3Storagegs://bucket/prefix→ :class:GCSStorage
Extra kwargs are forwarded to the backend constructor.
Raises¶
ValueError If the URI scheme is not supported.