NEW Apache Iceberg Integration

MynaDB exposes an Apache Iceberg REST Catalog interface, enabling multi-engine analytics over your time series data. External engines such as Apache Spark, Trino, DuckDB, and Apache Flink can discover and query MynaDB tables through the standard Iceberg REST Catalog API without any data copying or ETL.

⚙ Multi-Engine Analytics

The Iceberg integration lets you keep ingesting data through MynaDB's optimized write path while opening your data lake to the broader analytics ecosystem via the Iceberg table format.

REST Catalog API

MynaDB implements the Iceberg REST Catalog specification, providing a set of HTTP endpoints that external engines use to discover namespaces, list tables, retrieve table metadata, and plan scans.

Method Endpoint Description
GET /iceberg/v1/namespaces List all namespaces (catalogs/schemas)
GET /iceberg/v1/namespaces/:ns/tables List tables within a namespace
GET /iceberg/v1/namespaces/:ns/tables/:table Load table metadata (schema, partitioning, snapshots)
POST /iceberg/v1/namespaces/:ns/tables/:table/scan Plan a table scan with optional filters

List Namespaces

bash
# List all namespaces
curl http://localhost:7000/iceberg/v1/namespaces

# Response
{
  "namespaces": [
    ["mydb", "default"],
    ["mydb", "service_1"],
    ["metrics", "default"]
  ]
}

List Tables

bash
# List tables in a namespace
curl http://localhost:7000/iceberg/v1/namespaces/mydb.default/tables

# Response
{
  "identifiers": [
    { "namespace": ["mydb", "default"], "name": "cpu" },
    { "namespace": ["mydb", "default"], "name": "memory" },
    { "namespace": ["mydb", "default"], "name": "disk" }
  ]
}

Load Table Metadata

bash
# Get table metadata including schema, partitioning, and snapshots
curl http://localhost:7000/iceberg/v1/namespaces/mydb.default/tables/cpu

# Response includes Iceberg table metadata:
# - table-uuid, format-version, location
# - schema (column names, types, field IDs)
# - partition-spec (date partitioning)
# - current-snapshot-id, snapshots list
# - sort-order, properties

Plan a Table Scan

bash
# Plan a scan with filter pushdown
curl -X POST http://localhost:7000/iceberg/v1/namespaces/mydb.default/tables/cpu/scan \
  -H "Content-Type: application/json" \
  -d '{
    "select": ["time", "host", "usage"],
    "filter": {
      "type": "and",
      "left": { "type": "gte", "column": "date", "value": "2026-01-01" },
      "right": { "type": "lt", "column": "date", "value": "2026-02-01" }
    }
  }'

# Response: list of data files to scan with statistics

Configuration

Enable and configure the Iceberg integration in your config.toml:

toml
[iceberg]
# Enable the Iceberg REST Catalog API
enabled = true

# Catalog name exposed to external engines
catalog_name = "mynadb"

# How often to sync Parquet files to Iceberg metadata (seconds)
sync_interval_secs = 30

# Directory for Iceberg metadata files (manifests, snapshots)
metadata_location = "/data0/mynadb/iceberg-metadata"
Parameter Default Description
enabled false Enable or disable the Iceberg REST Catalog endpoints
catalog_name "mynadb" The catalog name reported to external engines
sync_interval_secs 30 Interval between automatic metadata synchronization cycles
metadata_location "data/iceberg-metadata" Path where Iceberg metadata files are stored
⚠ Object Store Metadata

When using S3/MinIO/OSS as your storage backend, set metadata_location to a path within your object store bucket so that external engines can access both data and metadata files from the same storage layer.

Multi-Engine Support

Because MynaDB implements the Iceberg REST Catalog specification, any engine that supports Iceberg REST catalogs can read MynaDB tables directly. Below are configuration examples for popular analytics engines.

Apache Spark

python
from pyspark.sql import SparkSession

spark = SparkSession.builder \
    .appName("MynaDB Iceberg") \
    .config("spark.sql.catalog.mynadb", "org.apache.iceberg.spark.SparkCatalog") \
    .config("spark.sql.catalog.mynadb.type", "rest") \
    .config("spark.sql.catalog.mynadb.uri", "http://localhost:7000/iceberg/v1") \
    .getOrCreate()

# List namespaces
spark.sql("SHOW NAMESPACES IN mynadb").show()

# List tables
spark.sql("SHOW TABLES IN mynadb.default").show()

# Query time series data
df = spark.sql("""
    SELECT host, AVG(usage) as avg_cpu, MAX(usage) as max_cpu
    FROM mynadb.default.cpu
    WHERE date >= '2026-01-01'
    GROUP BY host
    ORDER BY avg_cpu DESC
""")
df.show()

Trino

properties
# etc/catalog/mynadb.properties
connector.name=iceberg
iceberg.catalog.type=rest
iceberg.rest-catalog.uri=http://localhost:7000/iceberg/v1
sql
-- Query MynaDB from Trino
SELECT host, region,
       AVG(usage) AS avg_cpu,
       COUNT(*) AS sample_count
FROM mynadb.default.cpu
WHERE date >= DATE '2026-01-01'
GROUP BY host, region
ORDER BY avg_cpu DESC;

DuckDB

sql
-- Install and load the Iceberg extension
INSTALL iceberg;
LOAD iceberg;

-- Attach MynaDB as an Iceberg REST catalog
ATTACH 'mynadb' AS mynadb (
    TYPE ICEBERG,
    ENDPOINT 'http://localhost:7000/iceberg/v1'
);

-- Query tables
SELECT host, AVG(usage) AS avg_cpu
FROM mynadb.default.cpu
WHERE date >= '2026-01-01'
GROUP BY host
ORDER BY avg_cpu DESC;

Apache Flink

sql
-- Register MynaDB Iceberg catalog in Flink SQL
CREATE CATALOG mynadb WITH (
    'type' = 'iceberg',
    'catalog-type' = 'rest',
    'uri' = 'http://localhost:7000/iceberg/v1'
);

-- Switch to the MynaDB catalog
USE CATALOG mynadb;
USE `default`;

-- Streaming read from MynaDB
SELECT host, usage, `time`
FROM cpu
WHERE date >= '2026-01-01';

Metadata Sync

MynaDB automatically synchronizes its internal Parquet files with Iceberg metadata. This process runs in the background so that external engines always see a consistent, up-to-date view of the data.

text
┌─────────────────────────────────────────────────────────────────────┐
│                          MynaDB                                    │
│                                                                    │
│  ┌──────────────┐    ┌──────────────┐    ┌───────────────────────┐ │
│  │  Write Path  │    │  Compactor   │    │  Iceberg Sync Job     │ │
│  │              │    │              │    │                       │ │
│  │  Parquet     │───>│  Merged      │───>│  Manifest Files       │ │
│  │  Files (L0)  │    │  Files (L1+) │    │  Snapshot Metadata    │ │
│  └──────────────┘    └──────────────┘    │  Table Metadata       │ │
│                                          └───────────┬───────────┘ │
└──────────────────────────────────────────────────────┼─────────────┘
                                                       │
                            ┌──────────────────────────┼──────────┐
                            │    Iceberg Metadata      │          │
                            │                          ▼          │
                            │    metadata/                        │
                            │    ├── v1.metadata.json             │
                            │    ├── v2.metadata.json             │
                            │    ├── snap-*.avro                  │
                            │    └── manifest-*.avro              │
                            └─────────────────────────────────────┘
                                                       │
                     ┌─────────────────────────────────┼──────────┐
                     │          External Engines        │          │
                     │    ┌─────┐  ┌───────┐  ┌──────┐ │          │
                     │    │Spark│  │ Trino │  │DuckDB│ │  ......  │
                     │    └─────┘  └───────┘  └──────┘ │          │
                     └─────────────────────────────────┴──────────┘

How It Works

  1. Parquet Discovery -- The sync job scans MynaDB's data directory for new or modified Parquet files at every sync_interval_secs interval.
  2. Schema Inference -- Column names, data types, and field IDs are extracted from Parquet file footers and mapped to the Iceberg schema format.
  3. Manifest Generation -- New Parquet files are grouped into Iceberg manifest files that record file paths, partition values, row counts, and column-level statistics.
  4. Snapshot Commit -- A new Iceberg snapshot is committed atomically, pointing to the updated set of manifest files. Previous snapshots are retained for time-travel queries.
  5. Metadata Update -- The table metadata JSON file is updated with the new current snapshot ID, ensuring external engines see the latest data on their next catalog refresh.
🕒 Near Real-Time

With the default sync_interval_secs = 30, new data written to MynaDB becomes visible to external Iceberg engines within 30 seconds. Reduce this value for lower latency at the cost of slightly higher metadata overhead.

Manual Sync

You can trigger an immediate metadata sync via the API:

bash
# Force an immediate Iceberg metadata sync
curl -X POST http://localhost:7000/iceberg/v1/sync

# Response
{
  "status": "ok",
  "tables_synced": 12,
  "snapshots_created": 5,
  "duration_ms": 230
}

Querying via Iceberg

Once the Iceberg integration is enabled, external engines can query MynaDB data using standard Iceberg table scans. MynaDB's date-based partitioning maps directly to Iceberg partition specs, enabling partition pruning in external engines.

Partition Pruning

Iceberg metadata includes partition statistics, allowing engines to skip irrelevant date partitions:

sql
-- Only scans Parquet files in the date=2026-02-* partitions
SELECT host, AVG(usage) AS avg_cpu
FROM mynadb.default.cpu
WHERE date >= '2026-02-01' AND date < '2026-03-01'
GROUP BY host;

Time Travel

Iceberg snapshots let you query data as it existed at a previous point in time:

sql
-- Spark: query a historical snapshot
SELECT * FROM mynadb.default.cpu VERSION AS OF 123456789;

-- Spark: query as of a timestamp
SELECT * FROM mynadb.default.cpu TIMESTAMP AS OF '2026-02-01 00:00:00';

Schema Evolution

When MynaDB detects new columns in incoming data, the Iceberg metadata is updated with the evolved schema on the next sync cycle. External engines automatically pick up the new columns.

sql
-- After adding a new "temperature" field via line protocol,
-- the column appears automatically in Iceberg queries
SELECT host, usage, temperature
FROM mynadb.default.cpu
WHERE date = '2026-02-13';

Cross-Engine Analytics Example

Combine MynaDB time series data with external datasets in Spark:

python
# Read time series from MynaDB via Iceberg
cpu_df = spark.sql("""
    SELECT host, date,
           AVG(usage) as avg_cpu,
           MAX(usage) as peak_cpu
    FROM mynadb.default.cpu
    WHERE date >= '2026-02-01'
    GROUP BY host, date
""")

# Read host metadata from a data lake
hosts_df = spark.read.parquet("s3://data-lake/hosts/")

# Join time series with metadata for enriched analytics
enriched = cpu_df.join(hosts_df, "host") \
    .select("host", "region", "team", "avg_cpu", "peak_cpu")

enriched.show()