Skip to content

Commit 9de213f

Browse files
authored
Merge pull request #301 from Canner/feature/add-redshift
Feature: add redshift extension
2 parents fa73cfd + 4712e07 commit 9de213f

18 files changed

+1635
-3
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# extension-driver-redshift
2+
3+
[@aws-sdk/client-redshift-data](https://www.npmjs.com/package/@aws-sdk/client-redshift-data) driver for VulcanSQL.
4+
5+
reference: https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-redshift-data
6+
7+
## Install
8+
9+
1. Install package
10+
11+
```bash
12+
npm i @vulcan-sql/extension-driver-redshift
13+
```
14+
15+
2. Update `vulcan.yaml`, enable the extension.
16+
17+
```yaml
18+
extensions:
19+
redshift: '@vulcan-sql/extension-driver-redshift'
20+
```
21+
22+
3. Create a new profile in `profiles.yaml` or in your profiles' paths. For example if you are using Redshift Serverless:
23+
24+
```yaml
25+
- name: redshift # profile name
26+
type: redshift
27+
allow: "*"
28+
connection:
29+
# please see the type definition of RedshiftDataClientConfig
30+
# https://github.com/aws/aws-sdk-js-v3/blob/29056f4ca545f7e5cf951b915bb52178305fc305/clients/client-redshift-data/src/RedshiftDataClient.ts#L253C18-L253C42
31+
credentials:
32+
accessKeyId: <AWS_ACCESS_KEY_ID>
33+
secretAccessKey: <AWS_SECRET_ACCESS_KEY>
34+
# please see the type definition of ExecuteStatementCommandInput(omit Sql and Parameters)
35+
# https://github.com/aws/aws-sdk-js-v3/blob/29056f4ca545f7e5cf951b915bb52178305fc305/clients/client-redshift-data/src/models/models_0.ts#L805C18-L805C39
36+
Database: <AWS_REDSHIFT_DATABASE>
37+
WorkgroupName: <AWS_REDSHIFT_WORKGROUP_NAME>
38+
```
39+
40+
## Testing
41+
42+
```bash
43+
nx test extension-driver-redshift
44+
```
45+
46+
This library was generated with [Nx](https://nx.dev).
47+
48+
To run test, the following environment variables are required:
49+
50+
- AWS_ACCESS_KEY_ID
51+
- AWS_SECRET_ACCESS_KEY
52+
- AWS_REDSHIFT_DATABASE
53+
- AWS_REDSHIFT_WORKGROUP_NAME
54+
55+
To enable the test for `test/redshiftDataSource.spec.ts`:
56+
- remove `.skip` inside `test/redshiftDataSource.spec.ts` to enable the test.
57+
- remove `/* istanbul ignore file */` in the `src/lib/redshiftDataSource.ts`
58+
59+
Local Testing Success Message:(Since the tests run in CI are disabled, so I paste the local testing result here!)
60+
61+
```bash
62+
PASS extension-driver-redshift packages/extension-driver-redshift/test/redshiftDataSource.spec.ts (41.595 s)
63+
64+
Test Suites: 2 passed, 2 total
65+
Tests: 15 passed, 15 total
66+
Snapshots: 0 total
67+
Time: 42.048 s
68+
Ran all test suites.
69+
70+
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
71+
72+
> NX Successfully ran target test for project extension-driver-redshift
73+
74+
75+
✨ Done in 44.39s.
76+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
displayName: 'extension-driver-redshift',
3+
preset: '../../jest.preset.ts',
4+
globals: {
5+
'ts-jest': {
6+
tsconfig: '<rootDir>/tsconfig.spec.json',
7+
},
8+
},
9+
transform: {
10+
'^.+\\.[tj]s$': 'ts-jest',
11+
},
12+
moduleFileExtensions: ['ts', 'js', 'html'],
13+
coverageDirectory: '../../coverage/packages/extension-driver-redshift',
14+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@vulcan-sql/extension-driver-redshift",
3+
"description": "Redshift driver for VulcanSQL",
4+
"version": "0.9.1",
5+
"type": "commonjs",
6+
"publishConfig": {
7+
"access": "public"
8+
},
9+
"keywords": [
10+
"vulcan",
11+
"vulcan-sql",
12+
"data",
13+
"sql",
14+
"database",
15+
"data-warehouse",
16+
"data-lake",
17+
"api-builder",
18+
"redshift"
19+
],
20+
"repository": {
21+
"type": "git",
22+
"url": "https://github.com/Canner/vulcan.git"
23+
},
24+
"license": "Apache-2.0",
25+
"dependencies": {
26+
"@aws-sdk/client-redshift-data": "^3.405.0",
27+
"exponential-backoff": "^3.1.1"
28+
},
29+
"peerDependencies": {
30+
"@vulcan-sql/core": "~0.9.1-0"
31+
}
32+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"root": "packages/extension-driver-redshift",
3+
"sourceRoot": "packages/extension-driver-redshift/src",
4+
"targets": {
5+
"build": {
6+
"executor": "@nrwl/workspace:run-commands",
7+
"options": {
8+
"command": "yarn ts-node ./tools/scripts/replaceAlias.ts extension-driver-redshift"
9+
},
10+
"dependsOn": [
11+
{
12+
"projects": "self",
13+
"target": "tsc"
14+
},
15+
{
16+
"projects": "self",
17+
"target": "install-dependencies"
18+
}
19+
]
20+
},
21+
"tsc": {
22+
"executor": "@nrwl/js:tsc",
23+
"outputs": ["{options.outputPath}"],
24+
"options": {
25+
"outputPath": "dist/packages/extension-driver-redshift",
26+
"main": "packages/extension-driver-redshift/src/index.ts",
27+
"tsConfig": "packages/extension-driver-redshift/tsconfig.lib.json",
28+
"assets": ["packages/extension-driver-redshift/*.md"],
29+
"buildableProjectDepsInPackageJsonType": "dependencies"
30+
},
31+
"dependsOn": [
32+
{
33+
"projects": "dependencies",
34+
"target": "build"
35+
},
36+
{
37+
"projects": "self",
38+
"target": "install-dependencies"
39+
}
40+
]
41+
},
42+
"lint": {
43+
"executor": "@nrwl/linter:eslint",
44+
"outputs": ["{options.outputFile}"],
45+
"options": {
46+
"lintFilePatterns": ["packages/extension-driver-redshift/**/*.ts"]
47+
}
48+
},
49+
"test": {
50+
"executor": "@nrwl/jest:jest",
51+
"outputs": ["coverage/packages/extension-driver-redshift"],
52+
"options": {
53+
"jestConfig": "packages/extension-driver-redshift/jest.config.ts",
54+
"passWithNoTests": true
55+
},
56+
"dependsOn": [
57+
{
58+
"projects": "self",
59+
"target": "install-dependencies"
60+
}
61+
]
62+
},
63+
"publish": {
64+
"executor": "@nrwl/workspace:run-commands",
65+
"options": {
66+
"command": "node ../../../tools/scripts/publish.mjs {args.tag} {args.version}",
67+
"cwd": "dist/packages/extension-driver-redshift"
68+
},
69+
"dependsOn": [
70+
{
71+
"projects": "self",
72+
"target": "build"
73+
}
74+
]
75+
},
76+
"install-dependencies": {
77+
"executor": "@nrwl/workspace:run-commands",
78+
"options": {
79+
"command": "yarn",
80+
"cwd": "packages/extension-driver-redshift"
81+
}
82+
}
83+
},
84+
"tags": []
85+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './lib/redshiftDataSource';
2+
import { RedShiftDataSource } from './lib/redshiftDataSource';
3+
export default [RedShiftDataSource];

0 commit comments

Comments
 (0)