All Products
Search
Document Center

E-MapReduce:Use Hudi

Last Updated:Jun 21, 2026

Apache Hudi is a data lake storage format that enables record-level inserts, updates, and deletes, along with change data capture for incremental processing. For more information, see Apache Hudi. This topic describes how to read from and write to Hudi tables in EMR Serverless Spark.

Prerequisites

A workspace is created. Create a workspace.

Procedure

Step 1: Create an SQL session

  1. Go to the Sessions page.

    1. Log on to the EMR console.

    2. In the left-side navigation pane, choose EMR Serverless > Spark.

    3. On the Spark page, click the name of the target workspace.

    4. On the EMR Serverless Spark page, click Sessions in the left-side navigation pane.

  2. On the SQL Session page, click Connect to SQL Session.

  3. On the Connect to SQL Session page, in the Spark Configuration section, add the following parameters and click create. For more information, see Manage SQL sessions.

    The configuration applies to the default catalog of the current workspace. To use an external Hive Metastore as the default catalog, see Connect to an external Hive Metastore Service.

    spark.sql.extensions             org.apache.spark.sql.hudi.HoodieSparkSessionExtension
    spark.sql.catalog.spark_catalog  org.apache.spark.sql.hudi.catalog.HoodieCatalog
    spark.serializer                 org.apache.spark.serializer.KryoSerializer

Step 2: Read and write a Hudi table

  1. Go to the development page.

    On the EMR Serverless Spark page, click Development in the left-side navigation pane.

  2. On the Development tab, click the image icon.

  3. In the Create dialog box, enter a name such as users_task, set the Type to the default SparkSQL, and then click OK.

  4. Paste the following code into the new Spark SQL tab (users_task).

    CREATE DATABASE IF NOT EXISTS ss_hudi_db;
    CREATE TABLE ss_hudi_db.hudi_tbl (id INT, name STRING) USING hudi TBLPROPERTIES (
      type = 'cow',
      primaryKey = 'id'
    );
    INSERT INTO ss_hudi_db.hudi_tbl VALUES (1, "a"), (2, "b");
    SELECT id, name FROM ss_hudi_db.hudi_tbl ORDER BY id;
    DROP TABLE ss_hudi_db.hudi_tbl;
    DROP DATABASE ss_hudi_db;
  5. From the drop-down lists, select a database and the SQL session that you just created.

  6. Click Run to execute the job.

    The result is a table that contains two records: one with id=1 and name=a, and the other with id=2 and name=b.

Related documents