DEV Community

Cover image for DELTA LAKE
Andres
Andres

Posted on • Edited on

DELTA LAKE

Existen diferentes arquitecturas para el procesammiento de datos, unas que llevan varios años como DWH, otras no tanto como un DataLake, sin embargo, ultimamente mi atencion se ha centrado en el tipo de almacenamiento Delta Lake.

Image description

Pero que es, a mi manera de verlo, es una almacenamiento de multiples fuentes de datos (estructurados, no estructurados, semi), que permite tener versiones de cada unos de estos datos, segun sean modificados y todo esto basado en formato .parquet.

Image description

para utilizarlo lo podemos hacer con spark, utilizando nuestra propia sesion, o con herramientas especializadas como Databricks.

Image description

para este caso realizaremos un ejemplo muy simple de una instalacion local con sparkelta Lake, necesitas instalar pyspark y delta-spark:

pip install pyspark delta-spark
Enter fullscreen mode Exit fullscreen mode

esta es un ejemplo muy simple de como utilizar nuestro delta lake

from pyspark.sql import SparkSession

spark = SparkSession.builder .appName("DeltaLakeExample")  .config("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension") \
    .config("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog") \
    .getOrCreate()

Enter fullscreen mode Exit fullscreen mode

Creacion de una tabla con spark dentro de nuestro datalake:

from pyspark.sql.types import StructType, StructField, StringType, IntegerType
from delta.tables import DeltaTable

schema = StructType([
    StructField("id", IntegerType(), True),
    StructField("name", StringType(), True),
    StructField("age", IntegerType(), True)
])

data = [(1, "Alice", 29), (8, "Bob", 31), (4, "Cathy", 25)]
df = spark.createDataFrame(data, schema)

df.write.format("delta").mode("overwrite").save("/tmp/delta-table")
delta_df = spark.read.format("delta").load("/tmp/delta-table")

delta_df.show()
Enter fullscreen mode Exit fullscreen mode

Como podemos ver Delta Lake es una infraestructura de datos muy poderosa y pertenece al stack moderno de datos, te dejo mas enlaces donde podemos ver mucha mas informacion :

https://delta.io/
https://learn.microsoft.com/es-es/azure/databricks/delta/

Hasta la proxima!!

-GuechaTech

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay