From 25666fa71c590b65e8c9091a6986aa261d92532a Mon Sep 17 00:00:00 2001 From: Liench Volodymyr Date: Mon, 25 Sep 2023 19:58:14 +0300 Subject: [PATCH 1/3] fix reading values on undefined --- dist/result/JsonResult.js | 4 ++-- dist/result/JsonResult.js.map | 2 +- lib/result/JsonResult.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/result/JsonResult.js b/dist/result/JsonResult.js index 1a45a61..68cbe98 100644 --- a/dist/result/JsonResult.js +++ b/dist/result/JsonResult.js @@ -40,9 +40,9 @@ var JsonResult = /** @class */ (function () { }; JsonResult.prototype.getRows = function (columns, descriptors) { var _this = this; - var columnStartPosition = Math.min.apply(Math, descriptors.map(function (d) { return d.position; })); + var columnStartPosition = Math.max(Math.min.apply(Math, descriptors.map(function (d) { return d.position; })), 0); return descriptors.reduce(function (rows, descriptor) { - return _this.getSchemaValues(descriptor, columns[descriptor.position - columnStartPosition]).reduce(function (result, value, i) { + return _this.getSchemaValues(descriptor, columns[descriptor.position - columnStartPosition] || {}).reduce(function (result, value, i) { if (!result[i]) { result[i] = {}; } diff --git a/dist/result/JsonResult.js.map b/dist/result/JsonResult.js.map index 45cde83..6854cd7 100644 --- a/dist/result/JsonResult.js.map +++ b/dist/result/JsonResult.js.map @@ -1 +1 @@ -{"version":3,"file":"JsonResult.js","sourceRoot":"","sources":["../../lib/result/JsonResult.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA8K;AAI9K;IAKI,oBAAY,iBAAmC;QAC3C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,iCAAY,GAAZ,UAAa,SAAqB;QAC9B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,OAAO,EAAE,CA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,EAAE,CAAS;QACnC,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAE/B,OAAO,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEO,2BAAM,GAAd,UAAe,KAAU,EAAE,YAAiB;QACxC,IAAI;YACA,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,YAAY,CAAC;SACvB;IACL,CAAC;IAEO,kCAAa,GAArB,UAAsB,KAAU;QAC5B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAEO,mCAAc,GAAtB,UAAuB,MAAc;QACjC,OAAO,MAAM,CAAC,kBAAU,CAAC,SAAS,CAAC;eAC5B,MAAM,CAAC,kBAAU,CAAC,OAAO,CAAC;eAC1B,MAAM,CAAC,kBAAU,CAAC,OAAO,CAAC;eAC1B,MAAM,CAAC,kBAAU,CAAC,SAAS,CAAC;eAC5B,MAAM,CAAC,kBAAU,CAAC,MAAM,CAAC;eACzB,MAAM,CAAC,kBAAU,CAAC,MAAM,CAAC;eACzB,MAAM,CAAC,kBAAU,CAAC,MAAM,CAAC;eACzB,MAAM,CAAC,kBAAU,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACL,iBAAC;AAAD,CAAC,AArJD,IAqJC"} \ No newline at end of file diff --git a/lib/result/JsonResult.ts b/lib/result/JsonResult.ts index 43feef6..751c106 100644 --- a/lib/result/JsonResult.ts +++ b/lib/result/JsonResult.ts @@ -46,11 +46,11 @@ export default class JsonResult implements IOperationResult { } private getRows(columns: Array, descriptors: Array): Array { - const columnStartPosition = Math.min(...descriptors.map(d => d.position)); + const columnStartPosition = Math.max(Math.min(...descriptors.map(d => d.position)), 0); return descriptors.reduce((rows, descriptor) => { return this.getSchemaValues( descriptor, - columns[descriptor.position - columnStartPosition] + columns[descriptor.position - columnStartPosition] || {} ).reduce((result, value, i) => { if (!result[i]) { result[i] = {}; From d2aa32e5cba2999863732c4b0e4c134ab941bc1e Mon Sep 17 00:00:00 2001 From: Liench Volodymyr Date: Mon, 25 Sep 2023 20:17:20 +0300 Subject: [PATCH 2/3] add more tests --- tests/unit/result/JsonResult.test.js | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/unit/result/JsonResult.test.js b/tests/unit/result/JsonResult.test.js index a2462be..e256a8d 100644 --- a/tests/unit/result/JsonResult.test.js +++ b/tests/unit/result/JsonResult.test.js @@ -292,4 +292,57 @@ describe('JsonResult', () => { "month_interval": null, }]); }); + + it('should check column that starts from 0', () => { + const schema = { + columns: [ + getColumnSchema('table.str_0', TCLIService_types.TTypeId.STRING_TYPE, 0), + getColumnSchema('table.str', TCLIService_types.TTypeId.STRING_TYPE, 1), + ] + }; + const data = [ + { + columns: [{ + stringVal: { values: ['a0', 'b0'] } + }, { + stringVal: { values: ['a', 'b'] } + }] + } + ]; + + const result = new JsonResult(TCLIService_types); + result.setOperation({ + getSchema: () => schema, + getData: () => data, + }); + + expect(result.getValue()).to.be.deep.eq([{ + "str":"a", + "str_0":"a0", + }, { + "str":"b", + "str_0":"b0", + }]); + }); + + it('should not fail if there is no column by descriptor', () => { + const schema = { + columns: [ + getColumnSchema('table.str', TCLIService_types.TTypeId.STRING_TYPE, 0), + ] + }; + const data = [ + { + columns: [] + } + ]; + + const result = new JsonResult(TCLIService_types); + result.setOperation({ + getSchema: () => schema, + getData: () => data, + }); + + expect(result.getValue()).to.be.deep.eq([]); + }); }); From 740e5e4e274aaf45b41383ccdd9ddfe85ab01a46 Mon Sep 17 00:00:00 2001 From: Liench Volodymyr Date: Mon, 25 Sep 2023 20:17:37 +0300 Subject: [PATCH 3/3] bump version 0.3.0 --- CHANGELOG.md | 10 ++++++++++ package-lock.json | 20 +++++++++----------- package.json | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 696287e..fbd6707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +[0.2.0](https://github.com/lenchv/hive-driver/releases/tag/v0.3.0) 2023-09-25 + +- Upgraded kerberos library + +- Added parameter "orientation" to fetch method in order to force using FETCH_NEXT as first operation after initialization schema + +- Fixed issue when on pending state the error was thrown + +- Fixed issue when in some cases colum was undefined when parsing JsonResult + [0.2.0](https://github.com/lenchv/hive-driver/releases/tag/v0.2.0) 2022-08-20 - Fixed an issue with zero-based column start (Spark Thrift Server, Kyuubi, for example) diff --git a/package-lock.json b/package-lock.json index b1b7191..61374bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hive-driver", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hive-driver", - "version": "0.2.0", + "version": "0.3.0", "license": "MIT", "dependencies": { "node-int64": "^0.4.0", @@ -798,6 +798,7 @@ }, "node_modules/ansi-styles": { "version": "3.2.1", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^1.9.0" @@ -1125,6 +1126,7 @@ }, "node_modules/chalk": { "version": "2.4.2", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", @@ -1256,6 +1258,7 @@ }, "node_modules/color-convert": { "version": "1.9.3", + "dev": true, "license": "MIT", "dependencies": { "color-name": "1.1.3" @@ -1263,6 +1266,7 @@ }, "node_modules/color-name": { "version": "1.1.3", + "dev": true, "license": "MIT" }, "node_modules/commander": { @@ -1775,6 +1779,7 @@ }, "node_modules/escape-string-regexp": { "version": "1.0.5", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.0" @@ -2205,6 +2210,7 @@ }, "node_modules/has-flag": { "version": "3.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -3756,15 +3762,6 @@ "node": ">=8" } }, - "node_modules/package-lock-only": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/package-lock-only/-/package-lock-only-0.0.4.tgz", - "integrity": "sha512-fV1YHeTMWH5LKmdVqfWskm2/SG0iF2IrxJn3ziaPVx9CnpecGJzt8xXtLV+CYINENZwPFMtbxO5qupz0asNz1A==", - "hasInstallScript": true, - "dependencies": { - "chalk": "^2.4.1" - } - }, "node_modules/parent-module": { "version": "1.0.1", "dev": true, @@ -4459,6 +4456,7 @@ }, "node_modules/supports-color": { "version": "5.5.0", + "dev": true, "license": "MIT", "dependencies": { "has-flag": "^3.0.0" diff --git a/package.json b/package.json index f1aae57..81df7f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hive-driver", - "version": "0.2.0", + "version": "0.3.0", "description": "Driver for connection to Apache Hive via Thrift API.", "main": "dist/index.js", "types": "dist/index.d.ts",