@cubejs-backend/hive-driver 0.32.0 → 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 +22 -0
- package/package.json +15 -4
- package/{driver → src}/HiveDriver.js +18 -18
- package/{driver → src}/TSaslTransport.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
|
|
17
|
+
## [0.32.2](https://github.com/cube-js/cube.js/compare/v0.32.1...v0.32.2) (2023-03-07)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* connection validation and logging ([#6233](https://github.com/cube-js/cube.js/issues/6233)) ([6dc48f8](https://github.com/cube-js/cube.js/commit/6dc48f8dc8045234dfa9fe8922534c5204e6e569))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [0.32.0](https://github.com/cube-js/cube.js/compare/v0.31.69...v0.32.0) (2023-03-02)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @cubejs-backend/hive-driver
|
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.
|
|
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": "
|
|
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
|
-
"@cubejs-backend/base-driver": "^0.32.
|
|
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
|
-
"
|
|
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
|
-
|
|
26
|
-
|
|
26
|
+
'2.1.1',
|
|
27
|
+
'2.2.3',
|
|
27
28
|
'2.3.4',
|
|
28
29
|
];
|
|
29
30
|
|
|
@@ -47,22 +48,15 @@ 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
|
-
super(
|
|
57
|
+
super({
|
|
58
|
+
testConnectionTimeout: config.testConnectionTimeout,
|
|
59
|
+
});
|
|
66
60
|
|
|
67
61
|
const dataSource =
|
|
68
62
|
config.dataSource ||
|
|
@@ -97,7 +91,7 @@ class HiveDriver extends BaseDriver {
|
|
|
97
91
|
);
|
|
98
92
|
const hiveConnection = new HiveConnection(configuration, idl);
|
|
99
93
|
hiveConnection.cursor = await hiveConnection.connect();
|
|
100
|
-
hiveConnection.cursor.getOperationStatus = function () {
|
|
94
|
+
hiveConnection.cursor.getOperationStatus = function getOperationStatus() {
|
|
101
95
|
return new Promise((resolve, reject) => {
|
|
102
96
|
const serviceType = this.Conn.IDL.ServiceType;
|
|
103
97
|
const request = new serviceType.TGetOperationStatusReq({
|
|
@@ -112,7 +106,7 @@ class HiveDriver extends BaseDriver {
|
|
|
112
106
|
res.operationState === serviceType.TOperationState.ERROR_STATE
|
|
113
107
|
) {
|
|
114
108
|
// eslint-disable-next-line no-unused-vars
|
|
115
|
-
const [
|
|
109
|
+
const [_errorMessage, _infoMessage, message] = HS2Util.getThriftErrorMessage(
|
|
116
110
|
res.status, 'ExecuteStatement operation fail'
|
|
117
111
|
);
|
|
118
112
|
|
|
@@ -143,7 +137,7 @@ class HiveDriver extends BaseDriver {
|
|
|
143
137
|
// eslint-disable-next-line no-underscore-dangle
|
|
144
138
|
const conn = await this.pool._factory.create();
|
|
145
139
|
try {
|
|
146
|
-
return await this.
|
|
140
|
+
return await this.handleQuery('SELECT 1', [], conn);
|
|
147
141
|
} finally {
|
|
148
142
|
// eslint-disable-next-line no-underscore-dangle
|
|
149
143
|
await this.pool._factory.destroy(conn);
|
|
@@ -156,12 +150,17 @@ class HiveDriver extends BaseDriver {
|
|
|
156
150
|
});
|
|
157
151
|
}
|
|
158
152
|
|
|
159
|
-
async query(query, values,
|
|
153
|
+
async query(query, values, _opts) {
|
|
154
|
+
return this.handleQuery(query, values);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async handleQuery(query, values, conn) {
|
|
160
158
|
values = values || [];
|
|
161
159
|
const sql = SqlString.format(query, values);
|
|
162
160
|
const connection = conn || await this.pool.acquire();
|
|
163
161
|
try {
|
|
164
162
|
const execResult = await connection.cursor.execute(sql);
|
|
163
|
+
// eslint-disable-next-line no-constant-condition
|
|
165
164
|
while (true) {
|
|
166
165
|
const status = await connection.cursor.getOperationStatus();
|
|
167
166
|
if (HS2Util.isFinish(connection.cursor, status)) {
|
|
@@ -174,6 +173,7 @@ class HiveDriver extends BaseDriver {
|
|
|
174
173
|
let allRows = [];
|
|
175
174
|
if (execResult.hasResultSet) {
|
|
176
175
|
const schema = await connection.cursor.getSchema();
|
|
176
|
+
// eslint-disable-next-line no-constant-condition
|
|
177
177
|
while (true) {
|
|
178
178
|
const results = await connection.cursor.fetchBlock();
|
|
179
179
|
allRows.push(...(results.rows));
|
|
@@ -196,12 +196,12 @@ class HiveDriver extends BaseDriver {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
async tablesSchema() {
|
|
199
|
-
const tables = await this.
|
|
199
|
+
const tables = await this.handleQuery(`show tables in ${this.config.dbName}`);
|
|
200
200
|
|
|
201
201
|
return {
|
|
202
202
|
[this.config.dbName]: (await Promise.all(tables.map(async table => {
|
|
203
203
|
const tableName = table.tab_name || table.tableName;
|
|
204
|
-
const columns = await this.
|
|
204
|
+
const columns = await this.handleQuery(`describe ${this.config.dbName}.${tableName}`);
|
|
205
205
|
return {
|
|
206
206
|
[tableName]: columns.map(c => ({ name: c.col_name, type: c.data_type }))
|
|
207
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
|
|
32
|
+
this.writeCursor += (sourceEnd - offset);
|
|
33
33
|
|
|
34
34
|
let frames = [this];
|
|
35
35
|
|