Data Lakehouse
Data Lakehouse
A combination of a data lake and a data warehouse. ACID + unstructured data.
Data Lakehouse
A combination of a data lake and a data warehouse. ACID + unstructured data.
A Data Lakehouse is a modern data architecture that combines the flexibility and low-cost storage of a Data Lake with the ACID transactions and schema management of a data warehouse. Open table formats such as Delta Lake, Apache Iceberg, and Apache Hudi have made this paradigm possible.
A lakehouse supports BI analytics, machine learning, and real-time streaming all in a single repository, and greatly reduces the data replication costs and ETL complexity that arose when lakes and warehouses were operated separately. Because it uses open formats, it avoids vendor lock-in and can be accessed from a variety of query engines.
Its key features include ACID transactions (preventing concurrent write conflicts), schema evolution (adding/changing columns with no downtime), time travel (querying/rolling back data as of a past point in time), and Z-Ordering (a data layout optimized for query patterns).
Databricks, Snowflake, AWS Lake Formation, Google BigLake, and others provide lakehouse architectures, and unified catalogs such as Unity Catalog or Polaris are used to manage data governance and access control.
# Delta Lake 기반 레이크하우스 아키텍처
from delta.tables import DeltaTable
from pyspark.sql import SparkSession
from pyspark.sql.functions import *
spark = SparkSession.builder \
.appName("Lakehouse") \
.config("spark.sql.extensions",
"io.delta.sql.DeltaSparkSessionExtension") \
.config("spark.sql.catalog.spark_catalog",
"org.apache.spark.sql.delta.catalog.DeltaCatalog") \
.getOrCreate()
# 1. ACID 트랜잭션으로 데이터 저장
orders_df = spark.read.json("s3://raw/orders/")
orders_df.write \
.format("delta") \
.mode("overwrite") \
.partitionBy("order_date") \
.save("s3://lakehouse/bronze/orders/")
# 2. 스키마 진화 - 새 컬럼 추가 (무중단)
spark.sql("""
ALTER TABLE delta.`s3://lakehouse/bronze/orders/`
ADD COLUMNS (loyalty_points INT)
""")
# 3. Merge (Upsert) 작업 - CDC 처리
delta_orders = DeltaTable.forPath(spark, "s3://lakehouse/bronze/orders/")
updates_df = spark.read.json("s3://raw/orders_updates/")
delta_orders.alias("target").merge(
updates_df.alias("source"),
"target.order_id = source.order_id"
).whenMatchedUpdate(set={
"status": "source.status",
"updated_at": "source.updated_at"
}).whenNotMatchedInsertAll().execute()
# 4. 타임 트래블 - 과거 시점 조회
historical = spark.read.format("delta") \
.option("versionAsOf", 5) \
.load("s3://lakehouse/bronze/orders/")
# 5. Z-Ordering으로 쿼리 최적화
spark.sql("""
OPTIMIZE delta.`s3://lakehouse/gold/orders/`
ZORDER BY (customer_id, order_date)
""")
print("Lakehouse operations completed!")
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free