-
Notifications
You must be signed in to change notification settings - Fork 22
Add live Redshift connector (driver_map + redshift extra) #284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aalttoaesto
wants to merge
4
commits into
MotleyAI:main
Choose a base branch
from
aalttoaesto:redshift-live-connector
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4a03998
Add live Redshift connection support (driver_map + redshift extra)
aalttoaesto 3f1e6ba
documentation
aalttoaesto 9e42562
Address CodeRabbit review on redshift PR
aalttoaesto 8efae01
Merge remote-tracking branch 'origin/main' into redshift-live-connector
aalttoaesto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,8 +32,23 @@ testcontainers suites. | |
|
|
||
| Unit tests for SQL generation; no live-instance verification. | ||
|
|
||
| Redshift, Trino/Presto (Athena uses the Presto dialect), Databricks/Spark, | ||
| Oracle. | ||
| Trino/Presto (Athena uses the Presto dialect), Databricks/Spark, Oracle. | ||
|
|
||
| **Redshift** is further along than the rest of this tier: `RedshiftDialect` | ||
| (SQL generation) has been code-covered here for a while, and the connection | ||
| layer — `driver_map["redshift"] = "redshift+redshift_connector"`, the | ||
| `motley-slayer[redshift]` extra, and a live integration suite | ||
| (`tests/integration/test_integration_redshift.py`, gated on `REDSHIFT_HOST` / | ||
| `REDSHIFT_DATABASE` / `REDSHIFT_USER` / `REDSHIFT_PASSWORD`) — now exist too. | ||
| The suite has passed manually against a live Redshift Serverless endpoint | ||
| (outside CI). It stays in Tier 2 rather than Tier 1 because the | ||
| `redshift-integration` CI job (`.github/workflows/ci.yml`) has not yet run it | ||
| against a live endpoint — CI secrets are deliberately not wired up yet, since | ||
| the only endpoint verified so far is a personal AWS resource, and pointing CI | ||
| at it would bill every contributor's CI run to that personal account. This | ||
| entry should move to Tier 1 once the CI job passes at least once against a | ||
| project-owned (non-personal) Redshift endpoint, the same skip-until-configured | ||
| way Snowflake/BigQuery started. | ||
|
Comment on lines
+35
to
+51
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would revert this: the fact that it has been manually tested once does not guarantee anything |
||
|
|
||
| ## Aggregation support | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Redshift example | ||
|
|
||
| Redshift is a Tier 2 dialect (see [database support](../../docs/database-support.md)): | ||
| `RedshiftDialect`'s SQL generation is unit-tested, and the connection layer added | ||
| alongside this example (`motley-slayer[redshift]`, `driver_map["redshift"]`) is | ||
| too. The connection layer has since passed manually against a live Redshift | ||
| Serverless endpoint (outside CI) — see the CI note under Known limitations. | ||
| Like Snowflake / BigQuery, there's no free local Docker image, so this example | ||
| needs a real cluster or Redshift Serverless workgroup. | ||
|
|
||
| ## 1. Install the extra | ||
|
|
||
| ```bash | ||
| pip install 'motley-slayer[redshift]' | ||
| ``` | ||
|
|
||
| The extra pulls in `sqlalchemy-redshift` + `redshift-connector`. | ||
|
|
||
| ## 2. Configure a connection | ||
|
|
||
| ```yaml | ||
| # slayer_data/datasources/rs.yaml | ||
| name: rs | ||
| type: redshift | ||
| host: mycluster.abc123.us-east-1.redshift.amazonaws.com | ||
| port: 5439 | ||
| database: dev | ||
| username: YOUR_USER | ||
| password: YOUR_PASSWORD | ||
| ``` | ||
|
|
||
| Or as a connection string, using `redshift-connector` (the default driver — | ||
| supports IAM auth and Redshift Serverless, not just password auth): | ||
|
|
||
| ```text | ||
| redshift+redshift_connector://YOUR_USER:YOUR_PASSWORD@mycluster.abc123.us-east-1.redshift.amazonaws.com:5439/dev | ||
| ``` | ||
|
|
||
| ## 3. Seed the demo schema | ||
|
|
||
| ```bash | ||
| python ../seed.py "redshift+redshift_connector://YOUR_USER:YOUR_PASSWORD@mycluster.abc123.us-east-1.redshift.amazonaws.com:5439/dev" | ||
| ``` | ||
|
|
||
| This drops + recreates the four canonical tables (`regions`, `customers`, | ||
| `products`, `orders`) and inserts the standard fixture dataset. | ||
|
|
||
| ## 4. Register the datasource and ingest | ||
|
|
||
| ```bash | ||
| slayer datasources create "redshift+redshift_connector://YOUR_USER:YOUR_PASSWORD@.../dev" --name rs --ingest | ||
| ``` | ||
|
|
||
| **Redshift allows declaring `FOREIGN KEY` constraints, but they're not | ||
| enforced, and whether they're reflected for auto-ingestion's join discovery | ||
| is unverified against a live cluster.** Treat this like the ClickHouse / | ||
| BigQuery examples rather than the Postgres / MySQL / Snowflake ones: assume | ||
| joins are **not** auto-generated, and add them manually to the model YAML | ||
| files under `slayer_data/models/` if you need cross-model rollups. | ||
|
|
||
| ## 5. Verify | ||
|
|
||
| ```bash | ||
| python verify.py | ||
| ``` | ||
|
|
||
| `verify.py` runs the same battery used by the other examples: schema/type | ||
| checks, aggregation matrix (`median`, `percentile`, `stddev_samp/pop`, | ||
| `var_samp/pop`, `corr`, `covar_samp/pop`), and `count_distinct_approx` — which | ||
| on Redshift compiles to the keyword-prefix form `APPROXIMATE COUNT(DISTINCT x)` | ||
| rather than a native aggregate function name. | ||
|
|
||
| ## Known limitations | ||
|
|
||
| - **No auto-discovered joins** (see step 4) — unverified either way; add | ||
| `joins:` manually until confirmed. | ||
| - **Not yet CI-verified.** `tests/integration/test_integration_redshift.py` | ||
| has passed manually against a live Redshift Serverless endpoint, but the | ||
| `redshift-integration` CI job still skips — `REDSHIFT_HOST` / | ||
| `REDSHIFT_DATABASE` / `REDSHIFT_USER` / `REDSHIFT_PASSWORD` repo secrets are | ||
| deliberately not configured yet, since the only endpoint verified so far is | ||
| a personal one and wiring it into CI would bill every contributor's run to | ||
| that account. Redshift moves to Tier 1 once the job passes against a | ||
| project-owned endpoint. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.