Skip to content

fix(redshift): detect existing DWH schema via svv_all_schemas#2789

Merged
Niels-b merged 1 commit into
mainfrom
fix/scs-1193-redshift-schema-existence
Jul 14, 2026
Merged

fix(redshift): detect existing DWH schema via svv_all_schemas#2789
Niels-b merged 1 commit into
mainfrom
fix/scs-1193-redshift-schema-existence

Conversation

@Niels-b

@Niels-b Niels-b commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

On Redshift, setting up the Diagnostics Warehouse (DWH) could fail with permission denied for database <db> when the target DWH schema already exists but the connecting user is not its owner.

Root cause

The DWH schema-existence check queried information_schema.schemata. On Redshift (Postgres-8 lineage) that view only lists schemas the current user ownsUSAGE/CREATE grants do not make a schema appear there. So a pre-created schema the service user could access came back as "missing", Soda issued CREATE SCHEMA, which needs CREATE on the database, and failed even though the schema already existed.

Because visibility depends on ownership rather than grants, the failure can look inconsistent across otherwise-identical setups: a user who owns the schema succeeds, while a user with only USAGE/CREATE on the same schema does not.

Fix

Override the schemas metadata query on Redshift to use pg_catalog.svv_all_schemas (visible by access, not ownership), consistent with the existing svv_tables / svv_columns overrides. The base dialect is unchanged (still information_schema.schemata) via a new build_schemas_metadata_from_clause() hook — no other data source is affected.

Result: the pre-existing schema is detected, CREATE SCHEMA is skipped, and no database-level CREATE privilege is required.

Verification

  • Unit — new test asserts Redshift emits svv_all_schemas; Postgres/base output unchanged.
  • Live Redshifttest_schema_exists returns correct results; reproduced the visibility gap directly (information_schema.schemata listed fewer schemas than svv_all_schemas, missing ones the user could access, including public).
  • soda-redshift/tests — 13 passed. Core integration suite — 168 passed, 8 skipped.
  • soda-extensions DWH suite against live Redshift (this branch) — DWH tests passed (config, check_results table, views, rows-diff, failed-rows, failed-keys).

CI

soda-extensions main workflow dispatched against this branch to confirm the DWH tests pass on Redshift:

🤖 Generated with Claude Code

The Diagnostics Warehouse existence check queried information_schema.schemata, which on Redshift only lists schemas the current user OWNS. A pre-provisioned DWH schema the service user merely has USAGE/CREATE on was therefore invisible, so Soda issued CREATE SCHEMA -- which needs CREATE-on-database and failed with 'permission denied for database' even though the schema already existed.

Override the schemas metadata query on Redshift to use pg_catalog.svv_all_schemas (visible by access, not ownership), matching the existing svv_tables/svv_columns overrides. Base dialect behaviour is unchanged via a new build_schemas_metadata_from_clause() hook.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Niels-b

Niels-b commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

CI: soda-extensions main workflow dispatched against this branch (Redshift, snapshotMode=off, cross-source disabled) to verify the DWH tests pass — https://github.com/sodadata/soda-extensions/actions/runs/29255799995

@sonarqubecloud

Copy link
Copy Markdown

@Niels-b Niels-b changed the title fix(redshift): detect existing DWH schema via svv_all_schemas (SCS-1193) fix(redshift): detect existing DWH schema via svv_all_schemas Jul 13, 2026
@Niels-b
Niels-b merged commit b3a2a9d into main Jul 14, 2026
22 checks passed
@Niels-b
Niels-b deleted the fix/scs-1193-redshift-schema-existence branch July 14, 2026 07:01
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.

2 participants