External Tables & Lakehouse Federation

Query local files, S3 objects, HTTP feeds, Delta Lake / Iceberg lakehouse tables, and Kafka streams via Parquet, CSV, JSON, and NDJSON.

3 min read SpydQL & Data Modeling

SpydDB federates external files, object stores, lakehouse table formats, and streaming topics directly into the query engine so you can filter, aggregate, and join external data alongside local ACID collections using one pipeline or SQL query.

Unlike tools that silently succeed on CREATE EXTERNAL TABLE and fail later at query time, SpydDB validates declarations fail-closed at DDL time—checking transports, connectors, option keys, headers, and Parquet footers immediately.


1. Supported Transports & Formats#

Transports (USING <kind>)#

TransportLocation ExampleBacking Capability
file"/var/data/events.parquet"Built-in local filesystem reader
s3"s3://bucket/prefix/orders.csv"S3 SigV4 object-store client (install_s3 / server S3 config)
http"https://feeds.example.com/rates.csv"Outbound HTTP(S) transport (install_transport with SSRF policy)
lake"s3://lake-bucket/warehouse/orders/"Snapshot resolver over local dir or object store
kafka"events"Streaming broker connector (install_connector)

File & Lake Formats (FORMAT "<fmt>")#

  • Columnar analytics: parquet (PAR1 header/footer validation, plain and dictionary encodings, snappy, gzip, zstd, and uncompressed column chunks)
  • Lakehouse logs: delta (_delta_log/*.json add/remove actions and _last_checkpoint), iceberg (metadata/vN.metadata.json + manifest lists), and hudi (.hoodie/hoodie.properties timeline)
  • Row-oriented & interchange: csv (RFC-4180 delimiter/quote rules, automatic type inference with optional explicit schema override), json (array of objects or single JSON object), ndjson / JSON Lines

2. Creating External Tables (CREATE EXTERNAL TABLE)#

Local CSV, JSON & Parquet Files#

sql
-- Parquet: schema and row counts are verified directly from the footer
create external table historical_ticks (
  symbol text,
  price_cents i64,
  ts timestamp
)
using file "/data/ticks_2026.parquet"
format "parquet";

-- JSON array of objects with explicit column mapping
create external table events (
  label text,
  id u64
)
using file "/data/events.json"
format "json";

-- Query and join with local collections identically to native tables
historical_ticks
| where symbol == "SPY" and price_cents > 50000
| agg count() as n, avg(price_cents) as avg_price;

S3 Object Storage & HTTP Feeds#

sql
create external table remote_orders (
  id u64,
  note text
)
using s3 "s3://analytics-bucket/exports/orders.csv"
format "csv";

create external table fx_rates (
  pair text,
  rate f64
)
using http "https://rates.example.internal/daily.csv"
format "csv";

Lakehouse Tables (USING lake)#

SpydDB reads the lakehouse commit log dynamically on every query, applying removals and commits written by external engines (such as Spark or Flink) without restarting or re-registering the external table:

sql
-- Delta Lake table in S3 (or MinIO)
create external table lake_orders (
  id i64,
  name text
)
using lake "s3://lake/warehouse/orders/"
format "delta";

-- Apache Iceberg table snapshot
create external table iceberg_events (
  event_id u64,
  region text
)
using lake "s3://lake/iceberg/events/"
format "iceberg";

-- Apache Hudi table timeline
create external table hudi_users (
  user_id u64,
  tier text
)
using lake "s3://lake/hudi/users/"
format "hudi";

lake_orders | where id > 1 | agg count() as n;

Kafka External Tables (USING kafka)#

sql
create external table kafka_events (
  id u64,
  label text
)
using kafka "events"
options (topic = "events")
format "json";

kafka_events | sort id | take 100;

Drop any external catalog registration cleanly without deleting underlying remote files:

sql
drop external table if exists lake_orders;

3. Format Strictness & Schema Rules#

SpydDB prioritizes exactness over silent data corruption:

  • CSV parsing (RFC-4180): Handles quoted delimiters ("a,b"), doubled inner quotes ("say ""hi"""), CR/CRLF/LF newlines, explicit empty unquoted fields as NULL, and quoted "" as empty string. When types are omitted, the reader samples 256 rows before locking each column type. Declaring column types explicitly guarantees identifier columns like "00421" stay text instead of collapsing into integers.
  • JSON & NDJSON strictness: Derives columns from the first record's keys; records in the same feed that add unexpected columns or omit fields fail loudly instead of silently returning shifted nulls.
  • Lakehouse honesty guarantee: If a Delta table uses column mapping, an Iceberg table relies on row-level equality/position delete files not supported by the snapshot reader, or a Hudi table uses Merge-on-Read (MoR), SpydDB returns an explicit Unsupported error naming the feature rather than returning wrong row counts.

4. Predicate Pushdown & Connector Registration#

Pushdown Capabilities#

Simple comparison predicates (=, <>, <, <=, >, >=) against declared columns can be pushed down to external connectors so remote scans avoid pulling unnecessary rows.

S3 & Embedded Transport Setup#

For MinIO and S3-compatible object stores:

bash
export SPYDDB_S3_ENDPOINT="http://127.0.0.1:9000"
export SPYDDB_S3_BUCKET="lake"
export SPYDDB_S3_ACCESS_KEY="spyddb"
export SPYDDB_S3_SECRET_KEY="spyddb-secret"

When embedding spyd-query directly in a Rust application, register transports and stream connectors before declaring tables:

rust
use spyd_connect::s3::S3Config;
use spyd_query::Database;

let db = Database::open(&config)?;
db.install_s3(S3Config::from_env()?);
// Also available: db.install_connector(...) and db.install_transport(...)

If an operator declares a kafka, s3, or http external table without the matching connector or transport installed, CREATE EXTERNAL TABLE fails immediately with instructions naming the missing registration (install_connector / install_transport), and typos inside options (...) are rejected at declaration time.