@cubejs-backend/dremio-driver 1.1.9 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.1.10](https://github.com/cube-js/cube/compare/v1.1.9...v1.1.10) (2024-12-16)
7
+
8
+
9
+ ### Features
10
+
11
+ * **dremio-driver:** Add Dremio Cloud Support ([#8956](https://github.com/cube-js/cube/issues/8956)) ([d2c2fcd](https://github.com/cube-js/cube/commit/d2c2fcdaf8944ea7dd27e73b63c0b151c317022e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [1.1.9](https://github.com/cube-js/cube/compare/v1.1.8...v1.1.9) (2024-12-08)
7
18
 
8
19
  **Note:** Version bump only for package @cubejs-backend/dremio-driver
package/README.md CHANGED
@@ -9,11 +9,26 @@
9
9
 
10
10
  Pure Javascript Dremio driver.
11
11
 
12
+ ## Dremio Cloud
13
+
14
+ To use this driver with [Dremio Cloud](https://docs.dremio.com/cloud/reference/api/), use the following setup:
15
+
16
+ | Environment Variable | Value |
17
+ | --------------------------- | -------------------------------------------------- |
18
+ | CUBEJS_DB_TYPE | dremio |
19
+ | CUBEJS_DB_URL | https://api.dremio.cloud/v0/projects/${PROJECT_ID} |
20
+ | CUBEJS_DB_NAME | ${DB_NAME} |
21
+ | CUBEJS_DB_DREMIO_AUTH_TOKEN | ${PERSONAL_ACCESS_TOKEN} |
22
+
23
+ > [!NOTE]
24
+ > When `CUBEJS_DB_URL` is set it takes precedence over `CUBEJS_DB_HOST` and it
25
+ > is assumed that the driver is connecting to the Dremio Cloud API.
26
+
12
27
  ## Support
13
28
 
14
- This package is **community supported** and should be used at your own risk.
29
+ This package is **community supported** and should be used at your own risk.
15
30
 
16
- While the Cube Dev team is happy to review and accept future community contributions, we don't have active plans for further development. This includes bug fixes unless they affect different parts of Cube.js. **We're looking for maintainers for this package.** If you'd like to become a maintainer, please contact us in Cube.js Slack.
31
+ While the Cube Dev team is happy to review and accept future community contributions, we don't have active plans for further development. This includes bug fixes unless they affect different parts of Cube.js. **We're looking for maintainers for this package.** If you'd like to become a maintainer, please contact us in Cube.js Slack.
17
32
 
18
33
  ## License
19
34
 
@@ -49,6 +49,14 @@ class DremioDriver extends BaseDriver {
49
49
  assertDataSource('default');
50
50
 
51
51
  this.config = {
52
+ dbUrl:
53
+ config.dbUrl ||
54
+ getEnv('dbUrl', { dataSource }) ||
55
+ '',
56
+ dremioAuthToken:
57
+ config.dremioAuthToken ||
58
+ getEnv('dremioAuthToken', { dataSource }) ||
59
+ '',
52
60
  host:
53
61
  config.host ||
54
62
  getEnv('dbHost', { dataSource }) ||
@@ -80,11 +88,20 @@ class DremioDriver extends BaseDriver {
80
88
  getEnv('dbPollMaxInterval', { dataSource })
81
89
  ) * 1000,
82
90
  };
83
- const protocol = (this.config.ssl === true || this.config.ssl === 'true')
84
- ? 'https'
85
- : 'http';
86
- this.config.url =
87
- `${protocol}://${this.config.host}:${this.config.port}`;
91
+
92
+ if (this.config.dbUrl) {
93
+ this.config.url = this.config.dbUrl;
94
+ this.config.apiVersion = '';
95
+ if (this.config.dremioAuthToken === '') {
96
+ throw new Error('dremioAuthToken is blank');
97
+ }
98
+ } else {
99
+ const protocol = (this.config.ssl === true || this.config.ssl === 'true')
100
+ ? 'https'
101
+ : 'http';
102
+ this.config.url = `${protocol}://${this.config.host}:${this.config.port}`;
103
+ this.config.apiVersion = '/api/v3';
104
+ }
88
105
  }
89
106
 
90
107
  /**
@@ -103,6 +120,20 @@ class DremioDriver extends BaseDriver {
103
120
  * @protected
104
121
  */
105
122
  async getToken() {
123
+ if (this.config.dremioAuthToken) {
124
+ const bearerToken = `Bearer ${this.config.dremioAuthToken}`;
125
+ await axios.get(
126
+ `${this.config.url}${this.config.apiVersion}/catalog`,
127
+ {
128
+ headers: {
129
+ Authorization: bearerToken
130
+ },
131
+ },
132
+ );
133
+
134
+ return bearerToken;
135
+ }
136
+
106
137
  if (this.authToken && this.authToken.expires > new Date().getTime()) {
107
138
  return `_dremio${this.authToken.token}`;
108
139
  }
@@ -129,7 +160,7 @@ class DremioDriver extends BaseDriver {
129
160
 
130
161
  return axios.request({
131
162
  method,
132
- url: `${this.config.url}${url}`,
163
+ url: `${this.config.url}${this.config.apiVersion}${url}`,
133
164
  headers: {
134
165
  Authorization: token
135
166
  },
@@ -141,7 +172,7 @@ class DremioDriver extends BaseDriver {
141
172
  * @protected
142
173
  */
143
174
  async getJobStatus(jobId) {
144
- const { data } = await this.restDremioQuery('get', `/api/v3/job/${jobId}`);
175
+ const { data } = await this.restDremioQuery('get', `/job/${jobId}`);
145
176
 
146
177
  if (data.jobState === 'FAILED') {
147
178
  throw new Error(data.errorMessage);
@@ -162,7 +193,7 @@ class DremioDriver extends BaseDriver {
162
193
  * @protected
163
194
  */
164
195
  async getJobResults(jobId, limit = 500, offset = 0) {
165
- return this.restDremioQuery('get', `/api/v3/job/${jobId}/results?offset=${offset}&limit=${limit}`);
196
+ return this.restDremioQuery('get', `/job/${jobId}/results?offset=${offset}&limit=${limit}`);
166
197
  }
167
198
 
168
199
  /**
@@ -171,7 +202,7 @@ class DremioDriver extends BaseDriver {
171
202
  * @return {Promise<*>}
172
203
  */
173
204
  async executeQuery(sql) {
174
- const { data } = await this.restDremioQuery('post', '/api/v3/sql', { sql });
205
+ const { data } = await this.restDremioQuery('post', '/sql', { sql });
175
206
  return data.id;
176
207
  }
177
208
 
@@ -216,7 +247,7 @@ class DremioDriver extends BaseDriver {
216
247
  }
217
248
 
218
249
  async refreshTablesSchema(path) {
219
- const { data } = await this.restDremioQuery('get', `/api/v3/catalog/by-path/${path}`);
250
+ const { data } = await this.restDremioQuery('get', `/catalog/by-path/${path}`);
220
251
  if (!data || !data.children) {
221
252
  return true;
222
253
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cubejs-backend/dremio-driver",
3
3
  "description": "Cube.js Dremio driver",
4
4
  "author": "Cube Dev, Inc.",
5
- "version": "1.1.9",
5
+ "version": "1.1.10",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/cube-js/cube.git",
@@ -17,9 +17,9 @@
17
17
  "lint:fix": "eslint driver/*.js"
18
18
  },
19
19
  "dependencies": {
20
- "@cubejs-backend/base-driver": "1.1.8",
21
- "@cubejs-backend/schema-compiler": "1.1.9",
22
- "@cubejs-backend/shared": "1.1.8",
20
+ "@cubejs-backend/base-driver": "1.1.10",
21
+ "@cubejs-backend/schema-compiler": "1.1.10",
22
+ "@cubejs-backend/shared": "1.1.10",
23
23
  "axios": "^0.21.1",
24
24
  "moment-timezone": "^0.5.31",
25
25
  "sqlstring": "^2.3.1"
@@ -38,5 +38,5 @@
38
38
  "eslintConfig": {
39
39
  "extends": "../cubejs-linter"
40
40
  },
41
- "gitHead": "dcc46c760ef73dfb735d4b6c382e6789668a1b82"
41
+ "gitHead": "8ff2eca3b6424510c1fad8f30079031f6445110d"
42
42
  }