Skip to content

feat: add --schema flag to print inferred CREATE TABLE DDL#186

Merged
vmvarela merged 1 commit into
masterfrom
issue-176/schema-flag
Jul 3, 2026
Merged

feat: add --schema flag to print inferred CREATE TABLE DDL#186
vmvarela merged 1 commit into
masterfrom
issue-176/schema-flag

Conversation

@vmvarela

Copy link
Copy Markdown
Owner

Summary

Adds a --schema flag that loads input data into SQLite and prints the inferred CREATE TABLE DDL to stdout without executing a query. Closes #176.

Changes

  • src/args.zig — Added SchemaArgs struct, SchemaWithFlags error variant, --schema flag parsing, mutual exclusivity checks, and help text.
  • src/modes/schema.zig (new) — runSchema() follows stats.zig pattern: opens in-memory DB, loads tables, queries sqlite_master, prints DDL.
  • src/main.zig — Import, dispatch, and error handler for schema mode.
  • build.zig — 16 integration tests covering stdin, files, types, --no-type-inference, TSV, JSON, empty input, and all mutual exclusivity combos.
  • README.md — Added --schema row to the flags table.

Usage

cat data.csv | sql-pipe --schema
# CREATE TABLE "t" ("name" TEXT, "age" INTEGER);

sql-pipe orders.csv customers.csv --schema
# CREATE TABLE "orders" (...);
# 
# CREATE TABLE "customers" (...);

Verification

  • zig build test — 264 steps pass
  • zig build unit-test — pass
  • ziglint — no regressions

@vmvarela vmvarela added the type:feature New functionality label Jun 30, 2026
@vmvarela vmvarela force-pushed the issue-176/schema-flag branch from 5436fcb to 95230f4 Compare July 3, 2026 14:57
@vmvarela vmvarela merged commit 95230f4 into master Jul 3, 2026
4 checks passed
@vmvarela vmvarela deleted the issue-176/schema-flag branch July 3, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --schema flag to show inferred CREATE TABLE DDL

1 participant