Create an Iceberg table with an explicit partition spec using Spark and the Iceberg Spark runtime

domain: iceberg.apache.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Add the Iceberg Spark runtime JAR to your Spark session and configure a catalog (e.g., spark.sql.catalog.my_catalog = org.apache.iceberg.spark.SparkCatalog) along with catalog properties pointing to your chosen catalog type.
  2. Create the table with CREATE TABLE my_catalog.db.events (id BIGINT, event_time TIMESTAMP, region STRING, payload STRING) USING iceberg in Spark SQL.
  3. Define a partition spec with PARTITIONED BY (days(event_time), region) to apply a day transform on the timestamp column alongside an identity partition on region.
  4. Insert data with INSERT INTO my_catalog.db.events VALUES (...) and verify partitions are created as expected by querying the partitions metadata table: SELECT * FROM my_catalog.db.events.partitions.
  5. Optionally alter the partition spec later with ALTER TABLE my_catalog.db.events ADD PARTITION FIELD bucket(16, id) to add a bucket transform without rewriting existing data.

Known gotchas

Related routes

Evolve an Iceberg partition spec using hidden partitioning without rewriting existing data
iceberg.apache.org · 5 steps · unrated
Configure Nessie as an Apache Iceberg catalog in Apache Spark
projectnessie.org · 6 steps · unrated
Perform Iceberg time travel queries using both snapshot ID and timestamp syntax across Spark and Trino
iceberg.apache.org · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans