@cubejs-backend/hive-driver 0.32.2 → 0.32.5

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
+ ## [0.32.5](https://github.com/cube-js/cube.js/compare/v0.32.4...v0.32.5) (2023-03-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **hive-driver:** Follow DriverInterface for query method, fix [#6281](https://github.com/cube-js/cube.js/issues/6281) ([#6282](https://github.com/cube-js/cube.js/issues/6282)) ([e81aba9](https://github.com/cube-js/cube.js/commit/e81aba9fd3dcf8b08092b9c7302067b230d1bbdc))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.32.2](https://github.com/cube-js/cube.js/compare/v0.32.1...v0.32.2) (2023-03-07)
7
18
 
8
19
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cubejs-backend/hive-driver",
3
3
  "description": "Cube.js Hive database driver",
4
4
  "author": "Cube Dev, Inc.",
5
- "version": "0.32.2",
5
+ "version": "0.32.5",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/cube-js/cube.js.git",
@@ -11,9 +11,14 @@
11
11
  "engines": {
12
12
  "node": "^14.0.0 || ^16.0.0 || >=17.0.0"
13
13
  },
14
- "main": "driver/HiveDriver.js",
14
+ "main": "src/HiveDriver.js",
15
+ "scripts": {
16
+ "lint": "eslint src/* --ext .ts",
17
+ "lint:fix": "eslint --fix src/* --ext .ts"
18
+ },
15
19
  "dependencies": {
16
20
  "@cubejs-backend/base-driver": "^0.32.2",
21
+ "@cubejs-backend/shared": "^0.32.2",
17
22
  "generic-pool": "^3.6.0",
18
23
  "jshs2": "^0.4.4",
19
24
  "sasl-plain": "^0.1.0",
@@ -22,8 +27,14 @@
22
27
  "thrift": "^0.9.3"
23
28
  },
24
29
  "license": "Apache-2.0",
30
+ "devDependencies": {
31
+ "@cubejs-backend/linter": "^0.32.0"
32
+ },
25
33
  "publishConfig": {
26
34
  "access": "public"
27
35
  },
28
- "gitHead": "8f3dafc3132004641e40c3750ea1762bed1a4a38"
36
+ "eslintConfig": {
37
+ "extends": "../cubejs-linter"
38
+ },
39
+ "gitHead": "229a9a9f57a61e018cf5443ac582d669e9f3aa6d"
29
40
  }
@@ -14,6 +14,7 @@ const genericPool = require('generic-pool');
14
14
  const { BaseDriver } = require('@cubejs-backend/base-driver');
15
15
  const Connection = require('jshs2/lib/Connection');
16
16
  const IDLFactory = require('jshs2/lib/common/IDLFactory');
17
+
17
18
  const {
18
19
  HS2Util,
19
20
  IDLContainer,
@@ -22,8 +23,8 @@ const {
22
23
  } = jshs2;
23
24
 
24
25
  const newIDL = [
25
- "2.1.1",
26
- "2.2.3",
26
+ '2.1.1',
27
+ '2.2.3',
27
28
  '2.3.4',
28
29
  ];
29
30
 
@@ -47,20 +48,11 @@ IDLFactory.extractConfig = (config) => {
47
48
 
48
49
  const TSaslTransport = require('./TSaslTransport');
49
50
 
50
- /**
51
- * Hive driver class.
52
- */
53
51
  class HiveDriver extends BaseDriver {
54
- /**
55
- * Returns default concurrency value.
56
- */
57
52
  static getDefaultConcurrency() {
58
53
  return 2;
59
54
  }
60
55
 
61
- /**
62
- * Class constructor.
63
- */
64
56
  constructor(config = {}) {
65
57
  super({
66
58
  testConnectionTimeout: config.testConnectionTimeout,
@@ -99,7 +91,7 @@ class HiveDriver extends BaseDriver {
99
91
  );
100
92
  const hiveConnection = new HiveConnection(configuration, idl);
101
93
  hiveConnection.cursor = await hiveConnection.connect();
102
- hiveConnection.cursor.getOperationStatus = function () {
94
+ hiveConnection.cursor.getOperationStatus = function getOperationStatus() {
103
95
  return new Promise((resolve, reject) => {
104
96
  const serviceType = this.Conn.IDL.ServiceType;
105
97
  const request = new serviceType.TGetOperationStatusReq({
@@ -114,7 +106,7 @@ class HiveDriver extends BaseDriver {
114
106
  res.operationState === serviceType.TOperationState.ERROR_STATE
115
107
  ) {
116
108
  // eslint-disable-next-line no-unused-vars
117
- const [errorMessage, infoMessage, message] = HS2Util.getThriftErrorMessage(
109
+ const [_errorMessage, _infoMessage, message] = HS2Util.getThriftErrorMessage(
118
110
  res.status, 'ExecuteStatement operation fail'
119
111
  );
120
112
 
@@ -145,7 +137,7 @@ class HiveDriver extends BaseDriver {
145
137
  // eslint-disable-next-line no-underscore-dangle
146
138
  const conn = await this.pool._factory.create();
147
139
  try {
148
- return await this.query('SELECT 1', [], conn);
140
+ return await this.handleQuery('SELECT 1', [], conn);
149
141
  } finally {
150
142
  // eslint-disable-next-line no-underscore-dangle
151
143
  await this.pool._factory.destroy(conn);
@@ -158,12 +150,17 @@ class HiveDriver extends BaseDriver {
158
150
  });
159
151
  }
160
152
 
161
- async query(query, values, conn) {
153
+ async query(query, values, _opts) {
154
+ return this.handleQuery(query, values);
155
+ }
156
+
157
+ async handleQuery(query, values, conn) {
162
158
  values = values || [];
163
159
  const sql = SqlString.format(query, values);
164
160
  const connection = conn || await this.pool.acquire();
165
161
  try {
166
162
  const execResult = await connection.cursor.execute(sql);
163
+ // eslint-disable-next-line no-constant-condition
167
164
  while (true) {
168
165
  const status = await connection.cursor.getOperationStatus();
169
166
  if (HS2Util.isFinish(connection.cursor, status)) {
@@ -176,6 +173,7 @@ class HiveDriver extends BaseDriver {
176
173
  let allRows = [];
177
174
  if (execResult.hasResultSet) {
178
175
  const schema = await connection.cursor.getSchema();
176
+ // eslint-disable-next-line no-constant-condition
179
177
  while (true) {
180
178
  const results = await connection.cursor.fetchBlock();
181
179
  allRows.push(...(results.rows));
@@ -198,12 +196,12 @@ class HiveDriver extends BaseDriver {
198
196
  }
199
197
 
200
198
  async tablesSchema() {
201
- const tables = await this.query(`show tables in ${this.config.dbName}`);
199
+ const tables = await this.handleQuery(`show tables in ${this.config.dbName}`);
202
200
 
203
201
  return {
204
202
  [this.config.dbName]: (await Promise.all(tables.map(async table => {
205
203
  const tableName = table.tab_name || table.tableName;
206
- const columns = await this.query(`describe ${this.config.dbName}.${tableName}`);
204
+ const columns = await this.handleQuery(`describe ${this.config.dbName}.${tableName}`);
207
205
  return {
208
206
  [tableName]: columns.map(c => ({ name: c.col_name, type: c.data_type }))
209
207
  };
@@ -29,7 +29,7 @@ class Frame {
29
29
  this.fullyRead = !requireMoreData;
30
30
  const sourceEnd = requireMoreData ? data.length : dataEnd;
31
31
  data.copy(this.buffer, this.writeCursor, offset, sourceEnd);
32
- this.writeCursor = this.writeCursor + (sourceEnd - offset);
32
+ this.writeCursor += (sourceEnd - offset);
33
33
 
34
34
  let frames = [this];
35
35