Skip to content

Commit e409abd

Browse files
committed
code polish
1 parent 58c39b1 commit e409abd

File tree

5 files changed

+50
-36
lines changed

5 files changed

+50
-36
lines changed

packages/cubejs-bigquery-driver/src/BigQueryDriver.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,12 @@ export class BigQueryDriver extends BaseDriver implements DriverInterface {
146146
}
147147
}
148148

149+
/**
150+
* Returns the configurable driver options
151+
* Note: It returns the unprefixed option names.
152+
* In case of using multisources options need to be prefixed manually.
153+
*/
149154
public static driverEnvVariables() {
150-
// TODO (buntarb): check how this method can/must be used with split
151-
// names by the data source.
152155
return [
153156
'CUBEJS_DB_BQ_PROJECT_ID',
154157
'CUBEJS_DB_BQ_KEY_FILE',

packages/cubejs-elasticsearch-driver/driver/ElasticSearchDriver.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ class ElasticSearchDriver extends BaseDriver {
8484
}
8585
}
8686

87+
/**
88+
* Returns the configurable driver options
89+
* Note: It returns the unprefixed option names.
90+
* In case of using multisources options need to be prefixed manually.
91+
*/
8792
static driverEnvVariables() {
88-
// TODO (buntarb): check how this method can/must be used with split
89-
// names by the data source.
9093
return [
9194
'CUBEJS_DB_URL',
9295
'CUBEJS_DB_ELASTIC_QUERY_FORMAT',

packages/cubejs-ksql-driver/src/KsqlDriver.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,12 @@ export class KsqlDriver extends BaseDriver implements DriverInterface {
346346
return `\`${identifier}\``;
347347
}
348348

349+
/**
350+
* Returns the configurable driver options
351+
* Note: It returns the unprefixed option names.
352+
* In case of using multisources options need to be prefixed manually.
353+
*/
349354
public static driverEnvVariables() {
350-
// TODO (buntarb): check how this method can/must be used with split
351-
// names by the data source.
352355
return [
353356
'CUBEJS_DB_URL',
354357
'CUBEJS_DB_USER',

packages/cubejs-mssql-driver/driver/MSSqlDriver.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,19 @@ class MSSqlDriver extends BaseDriver {
8282
this.initialConnectPromise = this.connectionPool.connect();
8383
}
8484

85+
/**
86+
* Returns the configurable driver options
87+
* Note: It returns the unprefixed option names.
88+
* In case of using multisources options need to be prefixed manually.
89+
*/
8590
static driverEnvVariables() {
86-
// TODO (buntarb): check how this method can/must be used with split
87-
// names by the data source.
8891
return [
89-
'CUBEJS_DB_HOST', 'CUBEJS_DB_NAME', 'CUBEJS_DB_PORT', 'CUBEJS_DB_USER', 'CUBEJS_DB_PASS', 'CUBEJS_DB_DOMAIN'
92+
'CUBEJS_DB_HOST',
93+
'CUBEJS_DB_NAME',
94+
'CUBEJS_DB_PORT',
95+
'CUBEJS_DB_USER',
96+
'CUBEJS_DB_PASS',
97+
'CUBEJS_DB_DOMAIN',
9098
];
9199
}
92100

@@ -97,8 +105,8 @@ class MSSqlDriver extends BaseDriver {
97105
/**
98106
* Executes query in streaming mode.
99107
*
100-
* @param {string} query
101-
* @param {Array} values
108+
* @param {string} query
109+
* @param {Array} values
102110
* @param {{ highWaterMark: number? }} options
103111
* @return {Promise<StreamTableDataWithTypes>}
104112
*/
@@ -151,7 +159,7 @@ class MSSqlDriver extends BaseDriver {
151159
* scale: number?,
152160
* precision: number?
153161
* }
154-
* }} fields
162+
* }} fields
155163
*/
156164
mapFields(fields) {
157165
return Object.keys(fields).map((field) => {

packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@
44
* @fileoverview The `SnowflakeDriver` and related types declaration.
55
*/
66

7-
import {
8-
getEnv,
9-
assertDataSource,
10-
} from '@cubejs-backend/shared';
7+
import { assertDataSource, getEnv, } from '@cubejs-backend/shared';
118
import snowflake, { Column, Connection, RowStatement } from 'snowflake-sdk';
129
import {
1310
BaseDriver,
11+
DownloadQueryResultsOptions,
12+
DownloadQueryResultsResult,
1413
DownloadTableCSVData,
14+
DownloadTableMemoryData,
15+
DriverCapabilities,
1516
DriverInterface,
1617
GenericDataBaseType,
17-
TableStructure,
18-
UnloadOptions,
1918
StreamOptions,
2019
StreamTableDataWithTypes,
21-
DownloadTableMemoryData,
22-
DownloadQueryResultsResult,
23-
DownloadQueryResultsOptions,
24-
DriverCapabilities,
20+
TableStructure,
21+
UnloadOptions,
2522
} from '@cubejs-backend/base-driver';
2623
import { formatToTimeZone } from 'date-fns-timezone';
2724
import fs from 'fs/promises';
@@ -198,9 +195,12 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
198195
return 8;
199196
}
200197

198+
/**
199+
* Returns the configurable driver options
200+
* Note: It returns the unprefixed option names.
201+
* In case of using multisources options need to be prefixed manually.
202+
*/
201203
public static driverEnvVariables() {
202-
// TODO (buntarb): check how this method can/must be used with split
203-
// names by the data source.
204204
return [
205205
'CUBEJS_DB_NAME',
206206
'CUBEJS_DB_USER',
@@ -211,9 +211,11 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
211211
'CUBEJS_DB_SNOWFLAKE_ROLE',
212212
'CUBEJS_DB_SNOWFLAKE_CLIENT_SESSION_KEEP_ALIVE',
213213
'CUBEJS_DB_SNOWFLAKE_AUTHENTICATOR',
214+
'CUBEJS_DB_SNOWFLAKE_OAUTH_TOKEN_PATH',
215+
'CUBEJS_DB_SNOWFLAKE_HOST',
216+
'CUBEJS_DB_SNOWFLAKE_PRIVATE_KEY',
214217
'CUBEJS_DB_SNOWFLAKE_PRIVATE_KEY_PATH',
215218
'CUBEJS_DB_SNOWFLAKE_PRIVATE_KEY_PASS',
216-
'CUBEJS_DB_SNOWFLAKE_OAUTH_TOKEN_PATH',
217219
'CUBEJS_DB_SNOWFLAKE_QUOTED_IDENTIFIERS_IGNORE_CASE',
218220
];
219221
}
@@ -257,10 +259,7 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
257259
privateKey += '\n';
258260
}
259261

260-
snowflake.configure({
261-
// TODO: Remove after release of https://github.com/snowflakedb/snowflake-connector-nodejs/pull/912
262-
logLevel: 'OFF' as any
263-
});
262+
snowflake.configure({ logLevel: 'OFF' });
264263

265264
this.config = {
266265
readOnly: false,
@@ -416,9 +415,7 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
416415
this.config.token = await this.readOAuthToken();
417416
}
418417

419-
const connection = snowflake.createConnection(this.config);
420-
421-
return connection;
418+
return snowflake.createConnection(this.config);
422419
}
423420

424421
/**
@@ -475,8 +472,8 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
475472
}
476473
}
477474

478-
// eslint-disable-next-line no-return-assign
479-
return this.connection = this.initConnection();
475+
this.connection = this.initConnection();
476+
return this.connection;
480477
}
481478

482479
/**
@@ -758,7 +755,7 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
758755
const hydrationMap = this.generateHydrationMap(stmt.getColumns());
759756
const types: {name: string, type: string}[] =
760757
this.getTypes(stmt);
761-
if (rows && rows.length && Object.keys(hydrationMap).length) {
758+
if (rows?.length && Object.keys(hydrationMap).length) {
762759
for (const row of rows) {
763760
for (const [field, toValue] of Object.entries(hydrationMap)) {
764761
if (row.hasOwnProperty(field)) {
@@ -922,6 +919,6 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
922919

923920
public async getTablesQuery(schemaName: string) {
924921
const tables = await super.getTablesQuery(schemaName.toUpperCase());
925-
return tables.map(t => ({ table_name: t.TABLE_NAME && t.TABLE_NAME.toLowerCase() }));
922+
return tables.map(t => ({ table_name: t.TABLE_NAME?.toLowerCase() }));
926923
}
927924
}

0 commit comments

Comments
 (0)