Latest
Databricks shows open source Spark on Google Cloud reading Unity Catalog Iceberg tables
Image: Databricks

Databricks shows open source Spark on Google Cloud reading Unity Catalog Iceberg tables

Chat about this article with your favourite AI tool

Databricks has published an end-to-end demonstration of open source Apache Spark on Google Cloud Dataproc reading and writing Unity Catalog managed Iceberg tables, with no Databricks-specific libraries on the cluster. The company says the tables are standard Apache Iceberg metadata and Parquet files in a customer’s own Google Cloud Storage bucket, so they are not tied to its platform.

Two routes to the same files

Databricks walks through two approaches on a plain Dataproc cluster. The first uses the Iceberg REST API, which Unity Catalog implements. Spark connects to it the way it would to any Iceberg REST catalog, reads an existing table, creates a new one and writes rows that Databricks can query immediately.

Databricks logo alongside diagram of Iceberg tables accessed from Google Cloud Dataproc
Image: Databricks

The second registers the table’s current metadata file in a Hive metastore using Iceberg’s standard register_table procedure. Databricks presents this only as a portability demonstration, showing that any Iceberg-capable catalog can pick up the same files.

What the setup involves

According to Databricks, the Spark configuration uses only stock Apache Iceberg artifacts from Maven Central: the Iceberg Spark runtime and the Iceberg GCP bundle. The company used Iceberg 1.10.0 on a Dataproc 2.3 image, which ships Spark 3.5 on Scala 2.12. The runtime version has to match the Spark and Scala versions on the image.

Administrators need to enable external data access on the Unity Catalog metastore and grant the connecting identity the EXTERNAL USE SCHEMA privilege. MODIFY and CREATE TABLE on the schema are required for writes. Databricks used a personal access token for speed, but recommends a service principal with OAuth for anything scheduled.

On the REST path, Unity Catalog issues short-lived, table-scoped GCS credentials when Spark loads a table. Databricks said the Dataproc cluster therefore needs no storage keys for that bucket, and governance, lineage and audit still apply to tables created from Dataproc.

Why Hive registration is read-only

Databricks is explicit about the limits of the Hive route. A registration points to one specific metadata file, so every later Databricks write, including INSERT, MERGE, UPDATE, DELETE and maintenance such as OPTIMIZE, leaves the Hive entry stale until it is dropped and registered again. The company suggests making that refresh the last step of the job that loads the table.

Writing through the Hive registration is worse. The commit moves only the Hive pointer, so Unity Catalog never sees it and the two catalogs end up with diverging histories. Databricks cited Apache Iceberg’s own documentation, which warns that registering the same metadata file in more than one catalog can cause missing updates, data loss and table corruption.

Its guidance is to keep each table owned by a single catalog. To move a table, Databricks says to unregister it from Unity Catalog and then register it in the destination. The UNREGISTER capability is in Private Preview, the company said. It also warns against using DROP TABLE with PURGE on a registered table, since that would delete data files belonging to the Databricks table.

REST API versus Hive registration

  • REST API: reads are always current, writes from Dataproc are visible in Databricks at once, and Unity Catalog governance applies on every call.
  • Hive registration: reads reflect the registered snapshot only, the Dataproc service account needs its own read access to the bucket, and governance applies only at registration.

Known limitations

Databricks said external clients cannot currently run table maintenance such as snapshot expiry or orphan file removal on the REST path. On Iceberg v3 tables, row-level changes from external engines must use copy-on-write or deletion vectors.

The same REST settings also work with other engines, Databricks said, naming Trino, Flink, PyIceberg, Snowflake and Dremio. The company has published runnable scripts for each step in a companion GitHub repository.

Source: Databricks Blog