Skip to content

fix: add system view fallback chain for Redshift schema discovery#38

Merged
luiscarbonel1991 merged 1 commit into
mainfrom
fix/redshift-svv-tables-fallback
Apr 2, 2026
Merged

fix: add system view fallback chain for Redshift schema discovery#38
luiscarbonel1991 merged 1 commit into
mainfrom
fix/redshift-svv-tables-fallback

Conversation

@luiscarbonel1991

Copy link
Copy Markdown
Owner

Summary

  • Add auto-detection of Redshift system views at initialization with fallback chain: svv_tablessvv_all_tablesinformation_schema
  • Fix schema discovery returning 0 tables on clusters with data sharing, Lake Formation, or Serverless configurations
  • Fix _get_table_columns missing database filter when using svv_all_columns (could return cross-DB columns)
  • Extract _process_bulk_rows and _get_tables_bulk_information_schema to avoid state mutation in fallback (concurrency safe)
  • Skip caching empty results to prevent 24h dead cache
  • Normalize schema name to lowercase for case-insensitive matching
  • Add 8 unit tests for detection chain, fallback, and row processing
  • Bump version to 0.2.0rc11

Problem

On some Redshift clusters, svv_tables returns 0 rows for users that DO have access to tables. Validated with direct probes:

View Result
svv_tables 0 tables
svv_all_tables 95 tables
information_schema.tables 95 tables

Test plan

  • 203 unit tests pass (195 existing + 8 new)
  • nlp2sql inspect against affected cluster — detects svv_all_tables, finds 95 tables
  • nlp2sql query generates valid SQL and executes against Redshift
  • Cache reuse verified: same schema loads from disk, different schema gets fresh query
  • Anti-cache: empty schema does not persist to disk cache

Closes #37

On some Redshift clusters (data sharing, Lake Formation, Serverless),
svv_tables returns empty results. Add auto-detection at init time with
fallback chain: svv_tables -> svv_all_tables -> information_schema.

- Probe each source with COUNT query, pick first with rows > 0
- Handle column name differences (table_schema vs schema_name)
- Filter svv_all_tables by current_database() to avoid cross-DB noise
- Add db_filter to _get_table_columns for cross-DB isolation
- Extract _process_bulk_rows and _get_tables_bulk_information_schema
  to avoid state mutation in fallback (concurrency safe)
- Skip caching empty results to prevent 24h dead cache
- Normalize schema name to lowercase
- Add 8 unit tests for detection chain and row processing

Closes #37
Bump version to 0.2.0rc11.
@luiscarbonel1991 luiscarbonel1991 self-assigned this Apr 2, 2026
@luiscarbonel1991 luiscarbonel1991 added bug Something isn't working enhancement New feature or request labels Apr 2, 2026
@luiscarbonel1991 luiscarbonel1991 merged commit 67537b3 into main Apr 2, 2026
1 check passed
@luiscarbonel1991 luiscarbonel1991 deleted the fix/redshift-svv-tables-fallback branch April 2, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Redshift adapter — svv_tables returns empty on some clusters, add fallback chain

1 participant