Skip to content

fix(server): allow R2 SQL metadata queries#294

Merged
siisee11 merged 1 commit into
mainfrom
codex/r2-sql-metadata-queries
Jun 26, 2026
Merged

fix(server): allow R2 SQL metadata queries#294
siisee11 merged 1 commit into
mainfrom
codex/r2-sql-metadata-queries

Conversation

@siisee11

Copy link
Copy Markdown
Contributor

One-Line Summary

Cloudflare R2 SQL sources can now run SHOW and DESCRIBE metadata queries through the normal query path.

User-Facing Changes

  • R2 SQL users can run metadata discovery commands such as SHOW TABLES, SHOW COLUMNS FROM ..., DESCRIBE ..., and DESC ....
  • Non-read-only R2 SQL statements continue to be rejected before execution.

Why This Changed

The shared SQL validator only accepted SELECT-shaped ASTs. Cloudflare R2 SQL uses Athena-style metadata commands for catalog exploration, so valid read-only discovery queries were rejected even though the provider connection test already used SHOW DATABASES.

How It Changed

  • Added a Cloudflare R2 SQL-only metadata statement allowlist for parser show and describe expressions.
  • Checked the leading SQL keyword before allowing metadata statements because the Athena parser can represent EXPLAIN SELECT as a describe expression.
  • Updated R2 SQL validation errors to name the expanded allowed query set.
  • Added validation and execution-path tests for R2 SQL metadata queries.

Bug Fixes

  • Under Cloudflare R2 SQL sources, catalog discovery queries such as SHOW TABLES were rejected as non-SELECT queries; this change allows those read-only metadata commands.

Extra Context / Decisions (Optional)

The expanded allowlist is scoped to cloudflare_r2_sql; other providers still accept SELECT-only queries through the shared validator.

Verification

  • MISE_TRUSTED_CONFIG_PATHS=$PWD/mise.toml mise exec -- bun run format
  • MISE_TRUSTED_CONFIG_PATHS=$PWD/mise.toml mise exec -- bunx turbo test --json --filter=@onequery/server
  • MISE_TRUSTED_CONFIG_PATHS=$PWD/mise.toml mise exec -- bunx turbo typecheck --json --filter=@onequery/server

Video / Screenshot (Optional)

  • N/A

@siisee11 siisee11 enabled auto-merge (squash) June 26, 2026 00:52
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
onequery-landing e6a7f3b Commit Preview URL

Branch Preview URL
Jun 26 2026, 12:58 AM

@siisee11 siisee11 force-pushed the codex/r2-sql-metadata-queries branch from 7a3b930 to e6a7f3b Compare June 26, 2026 00:56
@siisee11 siisee11 merged commit 681c27f into main Jun 26, 2026
8 checks passed
@siisee11 siisee11 deleted the codex/r2-sql-metadata-queries branch June 26, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant