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 src/dataenginex/core/medallion_architecture.py
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 | |
write(data, path, format)
abstractmethod
Write data to path in the given format.
Returns True on success, False on failure.
Source code in src/dataenginex/core/medallion_architecture.py
159 160 161 162 163 164 165 | |
read(path, format)
abstractmethod
Read data from path. Returns None on failure.
Source code in src/dataenginex/core/medallion_architecture.py
167 168 169 170 | |
delete(path)
abstractmethod
Delete the resource at path. Returns True on success.
Source code in src/dataenginex/core/medallion_architecture.py
172 173 174 175 | |
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 src/dataenginex/core/medallion_architecture.py
177 178 179 180 181 182 183 184 | |
exists(path)
abstractmethod
Return True if path exists in the backend.
Source code in src/dataenginex/core/medallion_architecture.py
186 187 188 189 | |
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 src/dataenginex/lakehouse/catalog.py
26 27 28 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 | |
to_dict()
Serialize the catalog entry to a plain dictionary.
Source code in src/dataenginex/lakehouse/catalog.py
60 61 62 63 64 65 | |
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 src/dataenginex/lakehouse/catalog.py
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 | |
register(entry)
Register or update a dataset entry.
Source code in src/dataenginex/lakehouse/catalog.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
get(name)
Retrieve an entry by name.
Source code in src/dataenginex/lakehouse/catalog.py
102 103 104 | |
search(*, layer=None, tags=None, owner=None, name_contains=None)
Search entries by criteria.
Source code in src/dataenginex/lakehouse/catalog.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
list_all()
Return all catalog entries.
Source code in src/dataenginex/lakehouse/catalog.py
127 128 129 | |
delete(name)
Remove an entry by name.
Source code in src/dataenginex/lakehouse/catalog.py
131 132 133 134 135 136 137 | |
summary()
High-level catalog statistics.
Source code in src/dataenginex/lakehouse/catalog.py
139 140 141 142 143 144 145 146 147 148 149 150 | |
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 src/dataenginex/lakehouse/partitioning.py
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 | |
partition_key(record)
Return a year=.../month=.../day=... key for record.
Source code in src/dataenginex/lakehouse/partitioning.py
53 54 55 56 57 58 59 60 61 | |
partition_path(record, base='')
Return base joined with the date partition key.
Source code in src/dataenginex/lakehouse/partitioning.py
63 64 65 66 | |
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 src/dataenginex/lakehouse/partitioning.py
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 | |
partition_key(record)
Return a bucket=NNNN key based on hashed field values.
Source code in src/dataenginex/lakehouse/partitioning.py
99 100 101 102 103 104 | |
partition_path(record, base='')
Return base joined with the hash-bucket partition key.
Source code in src/dataenginex/lakehouse/partitioning.py
106 107 108 109 | |
PartitionStrategy
Bases: ABC
Base class for partitioning strategies.
Source code in src/dataenginex/lakehouse/partitioning.py
22 23 24 25 26 27 28 29 30 31 32 33 | |
partition_key(record)
abstractmethod
Return the partition path segment for record.
Source code in src/dataenginex/lakehouse/partitioning.py
25 26 27 28 | |
partition_path(record, base='')
abstractmethod
Return the full relative path (base + partition) for record.
Source code in src/dataenginex/lakehouse/partitioning.py
30 31 32 33 | |
BigQueryStorage
Bases: StorageBackend
Google BigQuery storage backend.
Reads/writes JSON rows to BigQuery tables. Requires
google-cloud-bigquery at runtime.
Path convention: dataset.table — the path argument is split on
the first "." to derive the dataset and table identifiers.
Parameters
project_id:
GCP project ID.
dataset:
Default BigQuery dataset for operations when path does not
contain a "." separator. Defaults to "dex".
location:
BigQuery dataset location (default "US").
client:
Optional pre-configured bigquery.Client (useful for tests).
Source code in src/dataenginex/lakehouse/storage.py
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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
write(data, path, format=StorageFormat.BIGQUERY)
Load data (list of dicts) into a BigQuery table.
Source code in src/dataenginex/lakehouse/storage.py
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 | |
read(path, format=StorageFormat.BIGQUERY)
Query all rows from a BigQuery table.
Source code in src/dataenginex/lakehouse/storage.py
486 487 488 489 490 491 492 493 494 495 496 497 | |
delete(path)
Delete a BigQuery table.
Source code in src/dataenginex/lakehouse/storage.py
499 500 501 502 503 504 505 506 507 508 509 510 511 | |
list_objects(prefix='')
List tables in the dataset, optionally filtered by prefix.
Source code in src/dataenginex/lakehouse/storage.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 | |
exists(path)
Return True if the BigQuery table exists.
Source code in src/dataenginex/lakehouse/storage.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
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 src/dataenginex/lakehouse/storage.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
write(data, path, format=StorageFormat.PARQUET)
Write JSON-serialised data to GCS.
Source code in src/dataenginex/lakehouse/storage.py
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
read(path, format=StorageFormat.PARQUET)
Read JSON data from GCS.
Source code in src/dataenginex/lakehouse/storage.py
623 624 625 626 627 628 629 630 631 632 633 634 | |
delete(path)
Delete object from GCS.
Source code in src/dataenginex/lakehouse/storage.py
636 637 638 639 640 641 642 643 644 645 646 647 648 | |
list_objects(prefix='')
List GCS objects under prefix.
Source code in src/dataenginex/lakehouse/storage.py
650 651 652 653 654 655 656 657 658 659 | |
exists(path)
Return True if path exists in GCS.
Source code in src/dataenginex/lakehouse/storage.py
661 662 663 664 665 666 667 668 669 670 671 672 673 | |
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 src/dataenginex/lakehouse/storage.py
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 | |
write(data, path, format=StorageFormat.PARQUET)
Serialize data as JSON and write to path.
Source code in src/dataenginex/lakehouse/storage.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
read(path, format=StorageFormat.PARQUET)
Read and deserialize a JSON file at path.
Source code in src/dataenginex/lakehouse/storage.py
81 82 83 84 85 86 87 88 89 90 91 | |
delete(path)
Delete the JSON file at path if it exists.
Source code in src/dataenginex/lakehouse/storage.py
93 94 95 96 97 98 99 100 101 102 103 | |
list_objects(prefix='')
List JSON entries under prefix.
Source code in src/dataenginex/lakehouse/storage.py
113 114 115 116 117 118 119 120 121 122 | |
exists(path)
Return True if path has a corresponding JSON file.
Source code in src/dataenginex/lakehouse/storage.py
124 125 126 | |
ParquetStorage
Bases: StorageBackend
Parquet file storage backed by pyarrow.
Falls back to JsonStorage when pyarrow is not installed.
Source code in src/dataenginex/lakehouse/storage.py
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 | |
write(data, path, format=StorageFormat.PARQUET)
Write data as a Parquet file at path.
Source code in src/dataenginex/lakehouse/storage.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
read(path, format=StorageFormat.PARQUET)
Read a Parquet file at path and return records.
Source code in src/dataenginex/lakehouse/storage.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
delete(path)
Delete the Parquet file at path if it exists.
Source code in src/dataenginex/lakehouse/storage.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
list_objects(prefix='')
List Parquet entries under prefix.
Source code in src/dataenginex/lakehouse/storage.py
215 216 217 218 219 220 221 222 223 224 225 226 | |
exists(path)
Return True if path has a corresponding Parquet file.
Source code in src/dataenginex/lakehouse/storage.py
228 229 230 231 232 | |
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 src/dataenginex/lakehouse/storage.py
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 | |
write(data, path, format=StorageFormat.PARQUET)
Write JSON-serialised data to S3.
Source code in src/dataenginex/lakehouse/storage.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
read(path, format=StorageFormat.PARQUET)
Read JSON data from S3.
Source code in src/dataenginex/lakehouse/storage.py
312 313 314 315 316 317 318 319 320 321 322 323 324 | |
delete(path)
Delete object from S3.
Source code in src/dataenginex/lakehouse/storage.py
326 327 328 329 330 331 332 333 334 335 336 337 338 | |
list_objects(prefix='')
List S3 objects under prefix.
Source code in src/dataenginex/lakehouse/storage.py
340 341 342 343 344 345 346 347 348 349 350 | |
exists(path)
Return True if path exists in S3.
Source code in src/dataenginex/lakehouse/storage.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
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.
Source code in src/dataenginex/lakehouse/storage.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | |