Skip to main content
Upstream deployment example. This page uses community images, charts, or an upstream lab. Get Enterprise Edition installation files and confirm the supported image, chart, and operator versions for your release.

Overview

  • Deploy Object Storage, Apache Spark, Hudi, and the database using Docker compose
  • Load a tiny dataset into Hudi with Apache Spark
  • Configure the database to access the Hive Metastore using an external catalog
  • Query the data with the database where the data sits


DLA In addition to efficient analytics of local data, the database can work as the compute engine to analyze data stored in data lakes such as Apache Hudi, Apache Iceberg, and Delta Lake. One of the key features of the database is its external catalog, which acts as the linkage to an externally maintained metastore. This functionality provides users with the capability to query external data sources seamlessly, eliminating the need for data migration. As such, users can analyze data from different systems such as HDFS and Amazon S3, in various file formats such as Parquet, ORC, and CSV, etc. The preceding figure shows a data lake analytics scenario where the database is responsible for data computing and analysis, and the data lake is responsible for data storage, organization, and maintenance. Data lakes allow users to store data in open storage formats and use flexible schemas to produce reports on “single source of truth” for various BI, AI, ad-hoc, and reporting use cases. The database fully leverages the advantages of its vectorization engine and CBO, significantly improving the performance of data lake analytics.

Prerequisites

The database demo repository

Clone the StarRocks demo repository to your local machine. All the steps in this guide will be run from the demo/documentation-samples/hudi/ directory in the directory where you cloned the demo GitHub repo.

MinIO AIStor license

MinIO AIStor requires a license to run. You can use an existing license, or you can request a new MinIO AIStor Free Tier license. To request a new MinIO AIStor Free Tier license, go to the MinIO AIStor pricing page and select Get Started under the Free tier to obtain a free license. The free tier license allows you to run MinIO AIStor on a single compute resource with one or more drives. Save the license file as minio.license in the same directory as the docker-compose.yml file. The Docker Compose file mounts minio.license into the MinIO AIStor container. Without a valid license, MinIO AIStor starts but denies all S3 operations. For this guide, that is the demo/documentation-samples/hudi/ directory.

Docker

  • Docker Setup: For Mac, Please follow the steps as defined in Install Docker Desktop on Mac. For running Spark-SQL queries, please ensure at least 5 GB memory and 4 CPUs are allocated to Docker (See Docker → Preferences → Advanced). Otherwise, spark-SQL queries could be killed because of memory issues.
  • 20 GB free disk space assigned to Docker

SQL client

You can use the SQL client provided in the Docker environment, or use one on your system. Many MySQL compatible clients will work.

Configuration

Change directory into demo/documentation-samples/hudi and look at the files. This is not a tutorial on Hudi, so not every configuration file will be described; but it is important for the reader to know where to look to see how things are configured. In the hudi/ directory you will find the docker-compose.yml file which is used to launch and configure the services in Docker. Here is a list of those services and a brief description:

Docker services

Configuration files

In the hudi/conf/ directory you will find configuration files that get mounted in the spark-hudi container.
core-site.xml
This file contains the object storage related settings. Links for this and other items in More information at the end of this document.
spark-defaults.conf
Settings for Hive, MinIO, and Spark SQL.
hudi-defaults.conf
Default file used to silence warnings in the spark-shell.
hadoop-metrics2-hbase.properties
Empty file used to silence warnings in the spark-shell.
hadoop-metrics2-s3a-file-system.properties
Empty file used to silence warnings in the spark-shell.

Bringing up Demo Cluster

This demo system consists of the database, Hudi, MinIO, and Spark services. Run Docker compose to bring up the cluster:
Tip With many containers running, docker compose ps output is easier to read if you pipe it to jq:

Configure MinIO

When you run the Spark commands you will set the basepath for the table being created to an s3a URI:
In this step you will create the bucket huditest in MinIO. The MinIO console is running on port 9000.

Authenticate to MinIO

Open a browser to http://localhost:9000/ and authenticate. The username and password are specified in docker-compose.yml; they are admin and password.

Create a bucket

In the left navigation select Buckets, and then Create Bucket +. Name the bucket huditest and select Create Bucket Create bucket huditest

Create and populate a table, then sync it to Hive

Tip Run this command, and any other docker compose commands, from the directory containing the docker-compose.yml file. Open spark-shell in the spark-hudi service
Note There will be warnings when spark-shell starts about illegal reflective access. You can ignore these warnings. Run these commands at the scala> prompt to:
  • Configure this Spark session to load, process, and write data
  • Create a dataframe and write that to a Hudi table
  • Sync to the Hive Metastore
Note You will see a warning:
This can be ignored, the file will be created automatically during this spark-shell session. There will also be a warning:
This warning informs you that syncing a log file that is open for writes is not supported when using object storage. The file will only be synced when it is closed. See Stack Overflow. The final command in the above spark-shell session should exit the container, if it doesn’t press enter and it will exit.

Configure the database

Connect to the database

Connect to the database with the provided MySQL client provided by the starrocks-fe service, or use your favorite SQL client and configure it to connect using the MySQL protocol on localhost:9030.

Create the linkage between the database and Hudi

There is a link at the end of this guide with more information on external catalogs. The external catalog created in this step acts as the linkage to the Hive Metastore (HMS) running in Docker.

Use the new catalog

Query the data in Hudi with the database

Run this query twice, the first time may take around five seconds to complete as data is not yet cached in the database. The second query will be very quick.
Tip Some of the SQL queries in the database documentation end with \G instead of a semicolon. The \G causes the mysql CLI to render the query results vertically. Many SQL clients do not interpret vertical formatting output, so you should replace \G with ; if you are not using the mysql CLI.

Summary

This tutorial exposed you to the use of a database external catalog to show you that you can query your data where it sits using the Hudi external catalog. Many other integrations are available using Iceberg, Delta Lake, and JDBC catalogs. In this tutorial you:
  • Deployed the database and a Hudi/Spark/MinIO environment in Docker
  • Loaded a tiny dataset into Hudi with Apache Spark
  • Configured a database external catalog to provide access to the Hudi catalog
  • Queried the data with SQL in the database without copying the data from the data lake

More information

the database Catalogs Apache Hudi quickstart (includes Spark) Apache Hudi S3 configuration Apache Spark configuration docs