Using the Delta Lake framework in AWS Glue
AWS Glue 3.0 and later supports the Linux Foundation Delta Lake framework. Delta Lake is an
open-source data lake storage framework that helps you perform ACID transactions, scale
metadata handling, and unify streaming and batch data processing. This topic covers
available features for using your data in AWS Glue when you transport or store your data in a
Delta Lake table. To learn more about Delta Lake, see the official Delta Lake documentation
You can use AWS Glue to perform read and write operations on Delta Lake tables in Amazon S3, or
work with Delta Lake tables using the AWS Glue Data Catalog. Additional operations such as insert,
update, and Table batch reads and
writesDeltaTable.forPath
. For more information about the Delta Lake Python
library, see Welcome to
Delta Lake’s Python documentation page
The following table lists the version of Delta Lake included in each AWS Glue version.
AWS Glue version | Supported Delta Lake version |
---|---|
4.0 | 2.1.0 |
3.0 | 1.0.0 |
To learn more about the data lake frameworks that AWS Glue supports, see Using data lake frameworks with AWS Glue ETL jobs.
Enabling Delta Lake for AWS Glue
To enable Delta Lake for AWS Glue, complete the following tasks:
-
Specify
delta
as a value for the--datalake-formats
job parameter. For more information, see AWS Glue job parameters. -
Create a key named
--conf
for your AWS Glue job, and set it to the following value. Alternatively, you can set the following configuration usingSparkConf
in your script. These settings help Apache Spark correctly handle Delta Lake tables.spark.sql.extensions=io.delta.sql.DeltaSparkSessionExtension --conf spark.sql.catalog.spark_catalog=org.apache.spark.sql.delta.catalog.DeltaCatalog
Using a different Delta Lake version
To use a version of Delta lake that AWS Glue doesn't support, specify your own Delta Lake
JAR files using the --extra-jars
job parameter. Do not include
delta
as a value for the --datalake-formats
job
parameter. To use the Delta Lake Python library in this case, you must specify the library JAR files
using the --extra-py-files
job parameter. The Python library comes
packaged in the Delta Lake JAR files.
Example: Write a Delta Lake table to Amazon S3 and register it to the AWS Glue Data Catalog
The following AWS Glue ETL script demonstrates how to write a Delta Lake table to Amazon S3 and register the table to the AWS Glue Data Catalog.
Example: Read a Delta Lake table from Amazon S3 using the AWS Glue Data Catalog
The following AWS Glue ETL script reads the Delta Lake table that you created in Example: Write a Delta Lake table to Amazon S3 and register it to the AWS Glue Data Catalog.
Example: Insert a
DataFrame
into a Delta Lake table in Amazon S3 using the
AWS Glue Data Catalog
This example inserts data into the Delta Lake table that you created in Example: Write a Delta Lake table to Amazon S3 and register it to the AWS Glue Data Catalog.
Note
This example requires you to set the --enable-glue-datacatalog
job parameter in order to use the AWS Glue Data Catalog as an Apache Spark Hive metastore.
To learn more, see AWS Glue job
parameters.
Example: Read a Delta Lake table from Amazon S3 using the Spark API
This example reads a Delta Lake table from Amazon S3 using the Spark API.
Example: Write a Delta Lake table to Amazon S3 using Spark
This example writes a Delta Lake table to Amazon S3 using Spark.