diff --git a/lib/DBSQLClient.ts b/lib/DBSQLClient.ts index 57d7225d..de9d9114 100644 --- a/lib/DBSQLClient.ts +++ b/lib/DBSQLClient.ts @@ -1,4 +1,5 @@ import thrift from 'thrift'; +import Int64 from 'node-int64'; import { EventEmitter } from 'events'; import TCLIService from '../thrift/TCLIService'; @@ -7,7 +8,6 @@ import IDBSQLClient, { ClientOptions, ConnectionOptions, OpenSessionRequest } fr import IDriver from './contracts/IDriver'; import IClientContext, { ClientConfig } from './contracts/IClientContext'; import HiveDriver from './hive/HiveDriver'; -import { Int64 } from './hive/Types'; import DBSQLSession from './DBSQLSession'; import IDBSQLSession from './contracts/IDBSQLSession'; import IAuthentication from './connection/contracts/IAuthentication'; @@ -73,6 +73,9 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I private static getDefaultConfig(): ClientConfig { return { + directResultsDefaultMaxRows: 100000, + fetchChunkDefaultMaxRows: 100000, + arrowEnabled: true, useArrowNativeTypes: true, socketTimeout: 15 * 60 * 1000, // 15 minutes diff --git a/lib/DBSQLOperation.ts b/lib/DBSQLOperation.ts index 305e4c81..84bde915 100644 --- a/lib/DBSQLOperation.ts +++ b/lib/DBSQLOperation.ts @@ -33,8 +33,6 @@ import { OperationChunksIterator, OperationRowsIterator } from './utils/Operatio import HiveDriverError from './errors/HiveDriverError'; import IClientContext from './contracts/IClientContext'; -const defaultMaxRows = 100000; - interface DBSQLOperationConstructorOptions { handle: TOperationHandle; directResults?: TSparkDirectResults; @@ -176,8 +174,10 @@ export default class DBSQLOperation implements IOperation { setTimeout(resolve, 0); }); + const defaultMaxRows = this.context.getConfig().fetchChunkDefaultMaxRows; + const result = resultHandler.fetchNext({ - limit: options?.maxRows || defaultMaxRows, + limit: options?.maxRows ?? defaultMaxRows, disableBuffering: options?.disableBuffering, }); await this.failIfClosed(); @@ -186,7 +186,7 @@ export default class DBSQLOperation implements IOperation { .getLogger() .log( LogLevel.debug, - `Fetched chunk of size: ${options?.maxRows || defaultMaxRows} from operation with id: ${this.id}`, + `Fetched chunk of size: ${options?.maxRows ?? defaultMaxRows} from operation with id: ${this.id}`, ); return result; } diff --git a/lib/DBSQLSession.ts b/lib/DBSQLSession.ts index f49e9651..768b6b5e 100644 --- a/lib/DBSQLSession.ts +++ b/lib/DBSQLSession.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import stream from 'node:stream'; import util from 'node:util'; import { stringify, NIL } from 'uuid'; +import Int64 from 'node-int64'; import fetch, { HeadersInit } from 'node-fetch'; import { TSessionHandle, @@ -12,7 +13,6 @@ import { TSparkArrowTypes, TSparkParameter, } from '../thrift/TCLIService_types'; -import { Int64 } from './hive/Types'; import IDBSQLSession, { ExecuteStatementOptions, TypeInfoRequest, @@ -41,22 +41,35 @@ import IClientContext, { ClientConfig } from './contracts/IClientContext'; // Explicitly promisify a callback-style `pipeline` because `node:stream/promises` is not available in Node 14 const pipeline = util.promisify(stream.pipeline); -const defaultMaxRows = 100000; - interface OperationResponseShape { status: TStatus; operationHandle?: TOperationHandle; directResults?: TSparkDirectResults; } -function getDirectResultsOptions(maxRows: number | null = defaultMaxRows) { +export function numberToInt64(value: number | bigint | Int64): Int64 { + if (value instanceof Int64) { + return value; + } + + if (typeof value === 'bigint') { + const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT); + const view = new DataView(buffer); + view.setBigInt64(0, value, false); // `false` to use big-endian order + return new Int64(Buffer.from(buffer)); + } + + return new Int64(value); +} + +function getDirectResultsOptions(maxRows: number | bigint | Int64 | null | undefined, config: ClientConfig) { if (maxRows === null) { return {}; } return { getDirectResults: { - maxRows: new Int64(maxRows), + maxRows: numberToInt64(maxRows ?? config.directResultsDefaultMaxRows), }, }; } @@ -86,7 +99,6 @@ function getArrowOptions(config: ClientConfig): { } function getQueryParameters( - sessionHandle: TSessionHandle, namedParameters?: Record, ordinalParameters?: Array, ): Array { @@ -184,12 +196,12 @@ export default class DBSQLSession implements IDBSQLSession { const operationPromise = driver.executeStatement({ sessionHandle: this.sessionHandle, statement, - queryTimeout: options.queryTimeout, + queryTimeout: options.queryTimeout ? numberToInt64(options.queryTimeout) : undefined, runAsync: true, - ...getDirectResultsOptions(options.maxRows), + ...getDirectResultsOptions(options.maxRows, clientConfig), ...getArrowOptions(clientConfig), canDownloadResult: options.useCloudFetch ?? clientConfig.useCloudFetch, - parameters: getQueryParameters(this.sessionHandle, options.namedParameters, options.ordinalParameters), + parameters: getQueryParameters(options.namedParameters, options.ordinalParameters), canDecompressLZ4Result: clientConfig.useLZ4Compression && Boolean(LZ4), }); const response = await this.handleResponse(operationPromise); @@ -339,10 +351,11 @@ export default class DBSQLSession implements IDBSQLSession { public async getTypeInfo(request: TypeInfoRequest = {}): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getTypeInfo({ sessionHandle: this.sessionHandle, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -357,10 +370,11 @@ export default class DBSQLSession implements IDBSQLSession { public async getCatalogs(request: CatalogsRequest = {}): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getCatalogs({ sessionHandle: this.sessionHandle, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -375,12 +389,13 @@ export default class DBSQLSession implements IDBSQLSession { public async getSchemas(request: SchemasRequest = {}): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getSchemas({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -395,6 +410,7 @@ export default class DBSQLSession implements IDBSQLSession { public async getTables(request: TablesRequest = {}): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getTables({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, @@ -402,7 +418,7 @@ export default class DBSQLSession implements IDBSQLSession { tableName: request.tableName, tableTypes: request.tableTypes, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -417,10 +433,11 @@ export default class DBSQLSession implements IDBSQLSession { public async getTableTypes(request: TableTypesRequest = {}): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getTableTypes({ sessionHandle: this.sessionHandle, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -435,6 +452,7 @@ export default class DBSQLSession implements IDBSQLSession { public async getColumns(request: ColumnsRequest = {}): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getColumns({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, @@ -442,7 +460,7 @@ export default class DBSQLSession implements IDBSQLSession { tableName: request.tableName, columnName: request.columnName, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -457,13 +475,14 @@ export default class DBSQLSession implements IDBSQLSession { public async getFunctions(request: FunctionsRequest): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getFunctions({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, functionName: request.functionName, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -472,13 +491,14 @@ export default class DBSQLSession implements IDBSQLSession { public async getPrimaryKeys(request: PrimaryKeysRequest): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getPrimaryKeys({ sessionHandle: this.sessionHandle, catalogName: request.catalogName, schemaName: request.schemaName, tableName: request.tableName, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); @@ -493,6 +513,7 @@ export default class DBSQLSession implements IDBSQLSession { public async getCrossReference(request: CrossReferenceRequest): Promise { await this.failIfClosed(); const driver = await this.context.getDriver(); + const clientConfig = this.context.getConfig(); const operationPromise = driver.getCrossReference({ sessionHandle: this.sessionHandle, parentCatalogName: request.parentCatalogName, @@ -502,7 +523,7 @@ export default class DBSQLSession implements IDBSQLSession { foreignSchemaName: request.foreignSchemaName, foreignTableName: request.foreignTableName, runAsync: true, - ...getDirectResultsOptions(request.maxRows), + ...getDirectResultsOptions(request.maxRows, clientConfig), }); const response = await this.handleResponse(operationPromise); return this.createOperation(response); diff --git a/lib/connection/auth/DatabricksOAuth/AuthorizationCode.ts b/lib/connection/auth/DatabricksOAuth/AuthorizationCode.ts index 03845c74..f6973a4d 100644 --- a/lib/connection/auth/DatabricksOAuth/AuthorizationCode.ts +++ b/lib/connection/auth/DatabricksOAuth/AuthorizationCode.ts @@ -4,6 +4,7 @@ import open from 'open'; import { LogLevel } from '../../../contracts/IDBSQLLogger'; import { OAuthScopes, scopeDelimiter } from './OAuthScope'; import IClientContext from '../../../contracts/IClientContext'; +import AuthenticationError from '../../../errors/AuthenticationError'; export interface AuthorizationCodeOptions { client: BaseClient; @@ -113,9 +114,9 @@ export default class AuthorizationCode { if (!receivedParams || !receivedParams.code) { if (receivedParams?.error) { const errorMessage = `OAuth error: ${receivedParams.error} ${receivedParams.error_description}`; - throw new Error(errorMessage); + throw new AuthenticationError(errorMessage); } - throw new Error(`No path parameters were returned to the callback at ${redirectUri}`); + throw new AuthenticationError(`No path parameters were returned to the callback at ${redirectUri}`); } return { code: receivedParams.code, verifier: verifierString, redirectUri }; @@ -152,7 +153,7 @@ export default class AuthorizationCode { } } - throw new Error('Failed to start server: all ports are in use'); + throw new AuthenticationError('Failed to start server: all ports are in use'); } private renderCallbackResponse(): string { diff --git a/lib/connection/auth/DatabricksOAuth/OAuthManager.ts b/lib/connection/auth/DatabricksOAuth/OAuthManager.ts index c1c41345..02bbde15 100644 --- a/lib/connection/auth/DatabricksOAuth/OAuthManager.ts +++ b/lib/connection/auth/DatabricksOAuth/OAuthManager.ts @@ -1,6 +1,6 @@ import http from 'http'; import { Issuer, BaseClient, custom } from 'openid-client'; -import HiveDriverError from '../../../errors/HiveDriverError'; +import AuthenticationError from '../../../errors/AuthenticationError'; import { LogLevel } from '../../../contracts/IDBSQLLogger'; import OAuthToken from './OAuthToken'; import AuthorizationCode from './AuthorizationCode'; @@ -104,7 +104,7 @@ export default abstract class OAuthManager { if (!token.refreshToken) { const message = `OAuth access token expired on ${token.expirationTime}.`; this.context.getLogger().log(LogLevel.error, message); - throw new HiveDriverError(message); + throw new AuthenticationError(message); } // Try to refresh using the refresh token @@ -115,7 +115,7 @@ export default abstract class OAuthManager { const client = await this.getClient(); const { access_token: accessToken, refresh_token: refreshToken } = await client.refresh(token.refreshToken); if (!accessToken || !refreshToken) { - throw new Error('Failed to refresh token: invalid response'); + throw new AuthenticationError('Failed to refresh token: invalid response'); } return new OAuthToken(accessToken, refreshToken, token.scopes); } @@ -165,7 +165,7 @@ export default abstract class OAuthManager { }); if (!accessToken) { - throw new Error('Failed to fetch access token'); + throw new AuthenticationError('Failed to fetch access token'); } return new OAuthToken(accessToken, refreshToken, mappedScopes); } @@ -185,7 +185,7 @@ export default abstract class OAuthManager { }); if (!accessToken) { - throw new Error('Failed to fetch access token'); + throw new AuthenticationError('Failed to fetch access token'); } return new OAuthToken(accessToken, undefined, mappedScopes); } @@ -234,7 +234,7 @@ export default abstract class OAuthManager { } } - throw new Error(`OAuth is not supported for ${options.host}`); + throw new AuthenticationError(`OAuth is not supported for ${options.host}`); } } diff --git a/lib/contracts/IClientContext.ts b/lib/contracts/IClientContext.ts index 712b845f..46c46c4b 100644 --- a/lib/contracts/IClientContext.ts +++ b/lib/contracts/IClientContext.ts @@ -4,6 +4,9 @@ import IConnectionProvider from '../connection/contracts/IConnectionProvider'; import TCLIService from '../../thrift/TCLIService'; export interface ClientConfig { + directResultsDefaultMaxRows: number; + fetchChunkDefaultMaxRows: number; + arrowEnabled?: boolean; useArrowNativeTypes?: boolean; socketTimeout: number; diff --git a/lib/contracts/IDBSQLSession.ts b/lib/contracts/IDBSQLSession.ts index ab5509ef..8a0d8bf0 100644 --- a/lib/contracts/IDBSQLSession.ts +++ b/lib/contracts/IDBSQLSession.ts @@ -1,16 +1,21 @@ +import Int64 from 'node-int64'; import IOperation from './IOperation'; import Status from '../dto/Status'; import InfoValue from '../dto/InfoValue'; -import { Int64 } from '../hive/Types'; import { DBSQLParameter, DBSQLParameterValue } from '../DBSQLParameter'; export type ExecuteStatementOptions = { - queryTimeout?: Int64; + /** + * The number of seconds after which the query will time out on the server. + * Effective only with Compute clusters. For SQL Warehouses, `STATEMENT_TIMEOUT` + * configuration should be used + */ + queryTimeout?: number | bigint | Int64; /** * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; useCloudFetch?: boolean; stagingAllowedLocalPath?: string | string[]; namedParameters?: Record; @@ -22,7 +27,7 @@ export type TypeInfoRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type CatalogsRequest = { @@ -30,7 +35,7 @@ export type CatalogsRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type SchemasRequest = { @@ -40,7 +45,7 @@ export type SchemasRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type TablesRequest = { @@ -52,7 +57,7 @@ export type TablesRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type TableTypesRequest = { @@ -60,7 +65,7 @@ export type TableTypesRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type ColumnsRequest = { @@ -72,7 +77,7 @@ export type ColumnsRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type FunctionsRequest = { @@ -83,7 +88,7 @@ export type FunctionsRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type PrimaryKeysRequest = { @@ -94,7 +99,7 @@ export type PrimaryKeysRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export type CrossReferenceRequest = { @@ -108,7 +113,7 @@ export type CrossReferenceRequest = { * @deprecated This option is no longer supported and will be removed in future releases */ runAsync?: boolean; - maxRows?: number | null; + maxRows?: number | bigint | Int64 | null; }; export default interface IDBSQLSession { diff --git a/lib/dto/InfoValue.ts b/lib/dto/InfoValue.ts index 4340b495..ec90f20e 100644 --- a/lib/dto/InfoValue.ts +++ b/lib/dto/InfoValue.ts @@ -1,5 +1,5 @@ +import Int64 from 'node-int64'; import { TGetInfoValue } from '../../thrift/TCLIService_types'; -import { Int64 } from '../hive/Types'; type InfoResultType = string | number | Buffer | Int64 | null; diff --git a/lib/hive/Types/index.ts b/lib/hive/Types/index.ts deleted file mode 100644 index e2eb4e5c..00000000 --- a/lib/hive/Types/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -import Int64 from 'node-int64'; -import { - TBoolColumn, - TByteColumn, - TI16Column, - TI32Column, - TI64Column, - TDoubleColumn, - TStringColumn, - TBinaryColumn, -} from '../../../thrift/TCLIService_types'; - -export { Int64 }; - -export enum ColumnCode { - boolVal = 'boolVal', - byteVal = 'byteVal', - i16Val = 'i16Val', - i32Val = 'i32Val', - i64Val = 'i64Val', - doubleVal = 'doubleVal', - stringVal = 'stringVal', - binaryVal = 'binaryVal', -} - -export type ColumnType = - | TBoolColumn - | TByteColumn - | TI16Column - | TI32Column - | TI64Column - | TDoubleColumn - | TStringColumn - | TBinaryColumn; - -export enum FetchType { - Data = 0, - Logs = 1, -} diff --git a/lib/polyfills.ts b/lib/polyfills.ts index 4d2c5632..006d38f1 100644 --- a/lib/polyfills.ts +++ b/lib/polyfills.ts @@ -46,7 +46,7 @@ const ArrayConstructors = [ ]; ArrayConstructors.forEach((ArrayConstructor) => { - if (!Object.prototype.hasOwnProperty.call(ArrayConstructor, 'at')) { + if (typeof ArrayConstructor.prototype.at !== 'function') { ArrayConstructor.prototype.at = at; } }); diff --git a/lib/result/JsonResultHandler.ts b/lib/result/JsonResultHandler.ts index 02a084af..2286b6dd 100644 --- a/lib/result/JsonResultHandler.ts +++ b/lib/result/JsonResultHandler.ts @@ -1,8 +1,7 @@ -import { ColumnCode } from '../hive/Types'; import { TGetResultSetMetadataResp, TRowSet, TColumn, TColumnDesc } from '../../thrift/TCLIService_types'; import IClientContext from '../contracts/IClientContext'; import IResultsProvider, { ResultsProviderFetchNextOptions } from './IResultsProvider'; -import { getSchemaColumns, convertThriftValue } from './utils'; +import { getSchemaColumns, convertThriftValue, getColumnValue } from './utils'; export default class JsonResultHandler implements IResultsProvider> { private readonly context: IClientContext; @@ -59,7 +58,7 @@ export default class JsonResultHandler implements IResultsProvider> { private getSchemaValues(descriptor: TColumnDesc, column?: TColumn): Array { const typeDescriptor = descriptor.typeDesc.types[0]?.primitiveEntry; - const columnValue = this.getColumnValue(column); + const columnValue = getColumnValue(column); if (!columnValue) { return []; @@ -79,20 +78,4 @@ export default class JsonResultHandler implements IResultsProvider> { return (byte & ofs) !== 0; } - - private getColumnValue(column?: TColumn) { - if (!column) { - return undefined; - } - return ( - column[ColumnCode.binaryVal] || - column[ColumnCode.boolVal] || - column[ColumnCode.byteVal] || - column[ColumnCode.doubleVal] || - column[ColumnCode.i16Val] || - column[ColumnCode.i32Val] || - column[ColumnCode.i64Val] || - column[ColumnCode.stringVal] - ); - } } diff --git a/lib/result/RowSetProvider.ts b/lib/result/RowSetProvider.ts index 5661d208..f3fa4213 100644 --- a/lib/result/RowSetProvider.ts +++ b/lib/result/RowSetProvider.ts @@ -1,14 +1,14 @@ -import { - TColumn, - TFetchOrientation, - TFetchResultsResp, - TOperationHandle, - TRowSet, -} from '../../thrift/TCLIService_types'; -import { ColumnCode, FetchType, Int64 } from '../hive/Types'; +import Int64 from 'node-int64'; +import { TFetchOrientation, TFetchResultsResp, TOperationHandle, TRowSet } from '../../thrift/TCLIService_types'; import Status from '../dto/Status'; import IClientContext from '../contracts/IClientContext'; import IResultsProvider, { ResultsProviderFetchNextOptions } from './IResultsProvider'; +import { getColumnValue } from './utils'; + +export enum FetchType { + Data = 0, + Logs = 1, +} function checkIfOperationHasMoreRows(response: TFetchResultsResp): boolean { if (response.hasMoreRows) { @@ -17,23 +17,8 @@ function checkIfOperationHasMoreRows(response: TFetchResultsResp): boolean { const columns = response.results?.columns || []; - if (columns.length === 0) { - return false; - } - - const column: TColumn = columns[0]; - - const columnValue = - column[ColumnCode.binaryVal] || - column[ColumnCode.boolVal] || - column[ColumnCode.byteVal] || - column[ColumnCode.doubleVal] || - column[ColumnCode.i16Val] || - column[ColumnCode.i32Val] || - column[ColumnCode.i64Val] || - column[ColumnCode.stringVal]; - - return (columnValue?.values?.length || 0) > 0; + const columnValue = getColumnValue(columns[0]); + return (columnValue?.values?.length ?? 0) > 0; } export default class RowSetProvider implements IResultsProvider { diff --git a/lib/result/utils.ts b/lib/result/utils.ts index 86edc776..4bbdf418 100644 --- a/lib/result/utils.ts +++ b/lib/result/utils.ts @@ -16,7 +16,7 @@ import { DateUnit, RecordBatchWriter, } from 'apache-arrow'; -import { TTableSchema, TColumnDesc, TPrimitiveTypeEntry, TTypeId } from '../../thrift/TCLIService_types'; +import { TTableSchema, TColumnDesc, TPrimitiveTypeEntry, TTypeId, TColumn } from '../../thrift/TCLIService_types'; import HiveDriverError from '../errors/HiveDriverError'; export interface ArrowBatch { @@ -145,3 +145,19 @@ export function hiveSchemaToArrowSchema(schema?: TTableSchema): Buffer | undefin writer.finish(); return Buffer.from(writer.toUint8Array(true)); } + +export function getColumnValue(column?: TColumn) { + if (!column) { + return undefined; + } + return ( + column.binaryVal ?? + column.boolVal ?? + column.byteVal ?? + column.doubleVal ?? + column.i16Val ?? + column.i32Val ?? + column.i64Val ?? + column.stringVal + ); +} diff --git a/nyc.config.js b/nyc.config.js index 6f776184..6a27b9fa 100644 --- a/nyc.config.js +++ b/nyc.config.js @@ -1,5 +1,9 @@ 'use strict'; module.exports = { + require: ['ts-node/register'], + reporter: ['lcov'], + all: true, + include: ['lib/**'], exclude: ['thrift/**', 'tests/**'], }; diff --git a/package-lock.json b/package-lock.json index 8fab7519..e3a63561 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,9 @@ "winston": "^3.8.2" }, "devDependencies": { + "@types/chai": "^4.3.14", "@types/lz4": "^0.6.4", + "@types/mocha": "^10.0.6", "@types/node": "^18.11.9", "@types/node-fetch": "^2.6.4", "@types/node-int64": "^0.4.29", @@ -43,6 +45,7 @@ "nyc": "^15.1.0", "prettier": "^2.8.4", "sinon": "^14.0.0", + "ts-node": "^10.9.2", "typescript": "^4.9.3" }, "engines": { @@ -591,6 +594,28 @@ "node": ">=0.1.90" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@dabh/diagnostics": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz", @@ -881,6 +906,36 @@ "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "node_modules/@types/chai": { + "version": "4.3.14", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.14.tgz", + "integrity": "sha512-Wj71sXE4Q4AkGdG9Tvq1u/fquNz9EdG4LIJMwVVII7ashjD/8cf8fyIfJAjRr6YcsXnSE8cOGQPq1gqeR8z+3w==", + "dev": true + }, "node_modules/@types/command-line-args": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.2.0.tgz", @@ -912,6 +967,12 @@ "@types/node": "*" } }, + "node_modules/@types/mocha": { + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", + "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", + "dev": true + }, "node_modules/@types/node": { "version": "18.11.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", @@ -1179,6 +1240,15 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", @@ -1312,6 +1382,12 @@ "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", "dev": true }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1928,6 +2004,12 @@ "url": "https://opencollective.com/core-js" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -4134,6 +4216,12 @@ "semver": "bin/semver.js" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -5765,6 +5853,58 @@ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/tsconfig-paths": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", @@ -5959,6 +6099,12 @@ "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -6199,6 +6345,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -6633,6 +6788,27 @@ "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==" }, + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + } + } + }, "@dabh/diagnostics": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz", @@ -6870,6 +7046,36 @@ "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, + "@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "@types/chai": { + "version": "4.3.14", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.14.tgz", + "integrity": "sha512-Wj71sXE4Q4AkGdG9Tvq1u/fquNz9EdG4LIJMwVVII7ashjD/8cf8fyIfJAjRr6YcsXnSE8cOGQPq1gqeR8z+3w==", + "dev": true + }, "@types/command-line-args": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.2.0.tgz", @@ -6901,6 +7107,12 @@ "@types/node": "*" } }, + "@types/mocha": { + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", + "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", + "dev": true + }, "@types/node": { "version": "18.11.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", @@ -7071,6 +7283,12 @@ "dev": true, "requires": {} }, + "acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "dev": true + }, "agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", @@ -7175,6 +7393,12 @@ "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", "dev": true }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -7627,6 +7851,12 @@ "integrity": "sha512-r1nJk41QLLPyozHUUPmILCEMtMw24NG4oWK6RbsDdjzQgg9ZvrUsPBj1MnG0wXXp1DCDU6j+wUvEmBSrtRbLXg==", "dev": true }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -9245,6 +9475,12 @@ } } }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -10452,6 +10688,35 @@ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, + "ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "dependencies": { + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + } + } + }, "tsconfig-paths": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", @@ -10589,6 +10854,12 @@ "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -10780,6 +11051,12 @@ } } }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 622ef2ef..48aa580c 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,9 @@ ], "license": "Apache 2.0", "devDependencies": { + "@types/chai": "^4.3.14", "@types/lz4": "^0.6.4", + "@types/mocha": "^10.0.6", "@types/node": "^18.11.9", "@types/node-fetch": "^2.6.4", "@types/node-int64": "^0.4.29", @@ -69,6 +71,7 @@ "nyc": "^15.1.0", "prettier": "^2.8.4", "sinon": "^14.0.0", + "ts-node": "^10.9.2", "typescript": "^4.9.3" }, "dependencies": { diff --git a/tests/e2e/arrow.test.js b/tests/e2e/arrow.test.js index f5127f6c..f1589433 100644 --- a/tests/e2e/arrow.test.js +++ b/tests/e2e/arrow.test.js @@ -2,10 +2,10 @@ const { expect } = require('chai'); const sinon = require('sinon'); const config = require('./utils/config'); const logger = require('./utils/logger')(config.logger); -const { DBSQLClient } = require('../..'); -const ArrowResultHandler = require('../../dist/result/ArrowResultHandler').default; -const ArrowResultConverter = require('../../dist/result/ArrowResultConverter').default; -const ResultSlicer = require('../../dist/result/ResultSlicer').default; +const { DBSQLClient } = require('../../lib'); +const ArrowResultHandler = require('../../lib/result/ArrowResultHandler').default; +const ArrowResultConverter = require('../../lib/result/ArrowResultConverter').default; +const ResultSlicer = require('../../lib/result/ResultSlicer').default; const fixtures = require('../fixtures/compatibility'); const { expected: expectedColumn } = require('../fixtures/compatibility/column'); diff --git a/tests/e2e/batched_fetch.test.js b/tests/e2e/batched_fetch.test.js index e22e1a8e..ec5cd51f 100644 --- a/tests/e2e/batched_fetch.test.js +++ b/tests/e2e/batched_fetch.test.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const config = require('./utils/config'); const logger = require('./utils/logger')(config.logger); -const { DBSQLClient } = require('../..'); +const { DBSQLClient } = require('../../lib'); async function openSession(customConfig) { const client = new DBSQLClient(); diff --git a/tests/e2e/cloudfetch.test.js b/tests/e2e/cloudfetch.test.js index a877f5af..04416d46 100644 --- a/tests/e2e/cloudfetch.test.js +++ b/tests/e2e/cloudfetch.test.js @@ -1,10 +1,10 @@ const { expect } = require('chai'); const sinon = require('sinon'); const config = require('./utils/config'); -const { DBSQLClient } = require('../..'); -const CloudFetchResultHandler = require('../../dist/result/CloudFetchResultHandler').default; -const ArrowResultConverter = require('../../dist/result/ArrowResultConverter').default; -const ResultSlicer = require('../../dist/result/ResultSlicer').default; +const { DBSQLClient } = require('../../lib'); +const CloudFetchResultHandler = require('../../lib/result/CloudFetchResultHandler').default; +const ArrowResultConverter = require('../../lib/result/ArrowResultConverter').default; +const ResultSlicer = require('../../lib/result/ResultSlicer').default; async function openSession(customConfig) { const client = new DBSQLClient(); diff --git a/tests/e2e/data_types.test.js b/tests/e2e/data_types.test.js index 59c24856..041e357e 100644 --- a/tests/e2e/data_types.test.js +++ b/tests/e2e/data_types.test.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const config = require('./utils/config'); const logger = require('./utils/logger')(config.logger); -const { DBSQLClient } = require('../..'); +const { DBSQLClient } = require('../../lib'); async function openSession(customConfig) { const client = new DBSQLClient(); diff --git a/tests/e2e/proxy.test.js b/tests/e2e/proxy.test.js index b7e48a33..ae67c110 100644 --- a/tests/e2e/proxy.test.js +++ b/tests/e2e/proxy.test.js @@ -3,7 +3,7 @@ const sinon = require('sinon'); const httpProxy = require('http-proxy'); const https = require('https'); const config = require('./utils/config'); -const { DBSQLClient } = require('../..'); +const { DBSQLClient } = require('../../lib'); class HttpProxyMock { constructor(target, port) { diff --git a/tests/e2e/query_parameters.test.js b/tests/e2e/query_parameters.test.js index 6efa5160..6de4f587 100644 --- a/tests/e2e/query_parameters.test.js +++ b/tests/e2e/query_parameters.test.js @@ -1,8 +1,8 @@ const { expect, AssertionError } = require('chai'); const Int64 = require('node-int64'); const config = require('./utils/config'); -const { DBSQLClient, DBSQLParameter, DBSQLParameterType } = require('../..'); -const ParameterError = require('../../dist/errors/ParameterError').default; +const { DBSQLClient, DBSQLParameter, DBSQLParameterType } = require('../../lib'); +const ParameterError = require('../../lib/errors/ParameterError').default; const openSession = async () => { const client = new DBSQLClient(); diff --git a/tests/e2e/staging_ingestion.test.js b/tests/e2e/staging_ingestion.test.js index b9cd3fea..01aa0318 100644 --- a/tests/e2e/staging_ingestion.test.js +++ b/tests/e2e/staging_ingestion.test.js @@ -4,8 +4,8 @@ const path = require('path'); const os = require('os'); const uuid = require('uuid'); const config = require('./utils/config'); -const { DBSQLClient } = require('../..'); -const StagingError = require('../../dist/errors/StagingError').default; +const { DBSQLClient } = require('../../lib'); +const StagingError = require('../../lib/errors/StagingError').default; describe('Staging Test', () => { const catalog = config.database[0]; diff --git a/tests/e2e/timeouts.test.js b/tests/e2e/timeouts.test.js index c535ce6b..a8b4b517 100644 --- a/tests/e2e/timeouts.test.js +++ b/tests/e2e/timeouts.test.js @@ -1,7 +1,7 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); const config = require('./utils/config'); -const { DBSQLClient } = require('../..'); +const { DBSQLClient } = require('../../lib'); async function openSession(socketTimeout, customConfig) { const client = new DBSQLClient(); diff --git a/tests/unit/DBSQLClient.test.js b/tests/unit/DBSQLClient.test.js index c12a64bf..3f149366 100644 --- a/tests/unit/DBSQLClient.test.js +++ b/tests/unit/DBSQLClient.test.js @@ -1,16 +1,13 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); -const DBSQLClient = require('../../dist/DBSQLClient').default; -const DBSQLSession = require('../../dist/DBSQLSession').default; +const DBSQLClient = require('../../lib/DBSQLClient').default; +const DBSQLSession = require('../../lib/DBSQLSession').default; -const PlainHttpAuthentication = require('../../dist/connection/auth/PlainHttpAuthentication').default; -const DatabricksOAuth = require('../../dist/connection/auth/DatabricksOAuth').default; -const { - DatabricksOAuthManager, - AzureOAuthManager, -} = require('../../dist/connection/auth/DatabricksOAuth/OAuthManager'); +const PlainHttpAuthentication = require('../../lib/connection/auth/PlainHttpAuthentication').default; +const DatabricksOAuth = require('../../lib/connection/auth/DatabricksOAuth').default; +const { DatabricksOAuthManager, AzureOAuthManager } = require('../../lib/connection/auth/DatabricksOAuth/OAuthManager'); -const HttpConnectionModule = require('../../dist/connection/connections/HttpConnection'); +const HttpConnectionModule = require('../../lib/connection/connections/HttpConnection'); const { default: HttpConnection } = HttpConnectionModule; diff --git a/tests/unit/DBSQLOperation.test.js b/tests/unit/DBSQLOperation.test.js index 99cc1e66..81e2be3a 100644 --- a/tests/unit/DBSQLOperation.test.js +++ b/tests/unit/DBSQLOperation.test.js @@ -1,16 +1,17 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); -const { DBSQLLogger, LogLevel } = require('../../dist'); +const { DBSQLLogger, LogLevel } = require('../../lib'); const { TStatusCode, TOperationState, TTypeId, TSparkRowSetType } = require('../../thrift/TCLIService_types'); -const DBSQLOperation = require('../../dist/DBSQLOperation').default; -const StatusError = require('../../dist/errors/StatusError').default; -const OperationStateError = require('../../dist/errors/OperationStateError').default; -const HiveDriverError = require('../../dist/errors/HiveDriverError').default; -const JsonResultHandler = require('../../dist/result/JsonResultHandler').default; -const ArrowResultConverter = require('../../dist/result/ArrowResultConverter').default; -const ArrowResultHandler = require('../../dist/result/ArrowResultHandler').default; -const CloudFetchResultHandler = require('../../dist/result/CloudFetchResultHandler').default; -const ResultSlicer = require('../../dist/result/ResultSlicer').default; +const DBSQLClient = require('../../lib/DBSQLClient').default; +const DBSQLOperation = require('../../lib/DBSQLOperation').default; +const StatusError = require('../../lib/errors/StatusError').default; +const OperationStateError = require('../../lib/errors/OperationStateError').default; +const HiveDriverError = require('../../lib/errors/HiveDriverError').default; +const JsonResultHandler = require('../../lib/result/JsonResultHandler').default; +const ArrowResultConverter = require('../../lib/result/ArrowResultConverter').default; +const ArrowResultHandler = require('../../lib/result/ArrowResultHandler').default; +const CloudFetchResultHandler = require('../../lib/result/CloudFetchResultHandler').default; +const ResultSlicer = require('../../lib/result/ResultSlicer').default; class OperationHandleMock { constructor(hasResultSet = true) { @@ -109,6 +110,10 @@ class ClientContextMock { this.driver = new DriverMock(); } + getConfig() { + return DBSQLClient.getDefaultConfig(); + } + getLogger() { return this.logger; } diff --git a/tests/unit/DBSQLParameter.test.js b/tests/unit/DBSQLParameter.test.js index dae92871..8f92ae29 100644 --- a/tests/unit/DBSQLParameter.test.js +++ b/tests/unit/DBSQLParameter.test.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const Int64 = require('node-int64'); const { TSparkParameterValue, TSparkParameter } = require('../../thrift/TCLIService_types'); -const { DBSQLParameter, DBSQLParameterType } = require('../../dist/DBSQLParameter'); +const { DBSQLParameter, DBSQLParameterType } = require('../../lib/DBSQLParameter'); describe('DBSQLParameter', () => { it('should infer types correctly', () => { diff --git a/tests/unit/DBSQLSession.test.js b/tests/unit/DBSQLSession.test.js index b172b29f..bfa5b4bc 100644 --- a/tests/unit/DBSQLSession.test.js +++ b/tests/unit/DBSQLSession.test.js @@ -1,12 +1,13 @@ const { expect, AssertionError } = require('chai'); -const { DBSQLLogger, LogLevel } = require('../../dist'); +const { DBSQLLogger, LogLevel } = require('../../lib'); const sinon = require('sinon'); -const DBSQLSession = require('../../dist/DBSQLSession').default; -const InfoValue = require('../../dist/dto/InfoValue').default; -const Status = require('../../dist/dto/Status').default; -const DBSQLOperation = require('../../dist/DBSQLOperation').default; -const HiveDriver = require('../../dist/hive/HiveDriver').default; -const DBSQLClient = require('../../dist/DBSQLClient').default; +const Int64 = require('node-int64'); +const { default: DBSQLSession, numberToInt64 } = require('../../lib/DBSQLSession'); +const InfoValue = require('../../lib/dto/InfoValue').default; +const Status = require('../../lib/dto/Status').default; +const DBSQLOperation = require('../../lib/DBSQLOperation').default; +const HiveDriver = require('../../lib/hive/HiveDriver').default; +const DBSQLClient = require('../../lib/DBSQLClient').default; // Create logger that won't emit // @@ -62,6 +63,30 @@ async function expectFailure(fn) { } describe('DBSQLSession', () => { + describe('numberToInt64', () => { + it('should convert regular number to Int64', () => { + const num = Math.random() * 1000000; + const value = numberToInt64(num); + expect(value.equals(new Int64(num))).to.be.true; + }); + + it('should return Int64 values as is', () => { + const num = new Int64(Math.random() * 1000000); + const value = numberToInt64(num); + expect(value).to.equal(num); + }); + + it('should convert BigInt to Int64', () => { + // This case is especially important, because Int64 has no native methods to convert + // between Int64 and BigInt. This conversion involves some byte operations, and it's + // important to make sure we don't mess up with things like byte order + + const num = BigInt(Math.round(Math.random() * 10000)) * BigInt(Math.round(Math.random() * 10000)); + const value = numberToInt64(num); + expect(value.toString()).equal(num.toString()); + }); + }); + describe('getInfo', () => { it('should run operation', async () => { const session = createSession(); diff --git a/tests/unit/connection/auth/DatabricksOAuth/AuthorizationCode.test.js b/tests/unit/connection/auth/DatabricksOAuth/AuthorizationCode.test.js index a9e61f4d..55338840 100644 --- a/tests/unit/connection/auth/DatabricksOAuth/AuthorizationCode.test.js +++ b/tests/unit/connection/auth/DatabricksOAuth/AuthorizationCode.test.js @@ -2,8 +2,8 @@ const { expect, AssertionError } = require('chai'); const { EventEmitter } = require('events'); const sinon = require('sinon'); const http = require('http'); -const { DBSQLLogger, LogLevel } = require('../../../../../dist'); -const AuthorizationCode = require('../../../../../dist/connection/auth/DatabricksOAuth/AuthorizationCode').default; +const { DBSQLLogger, LogLevel } = require('../../../../../lib'); +const AuthorizationCode = require('../../../../../lib/connection/auth/DatabricksOAuth/AuthorizationCode').default; const logger = new DBSQLLogger({ level: LogLevel.error }); diff --git a/tests/unit/connection/auth/DatabricksOAuth/OAuthManager.test.js b/tests/unit/connection/auth/DatabricksOAuth/OAuthManager.test.js index e3411cd1..8bd2af0b 100644 --- a/tests/unit/connection/auth/DatabricksOAuth/OAuthManager.test.js +++ b/tests/unit/connection/auth/DatabricksOAuth/OAuthManager.test.js @@ -1,15 +1,15 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); const openidClientLib = require('openid-client'); -const { DBSQLLogger, LogLevel } = require('../../../../../dist'); +const { DBSQLLogger, LogLevel } = require('../../../../../lib'); const { DatabricksOAuthManager, AzureOAuthManager, OAuthFlow, -} = require('../../../../../dist/connection/auth/DatabricksOAuth/OAuthManager'); -const OAuthToken = require('../../../../../dist/connection/auth/DatabricksOAuth/OAuthToken').default; -const { OAuthScope, scopeDelimiter } = require('../../../../../dist/connection/auth/DatabricksOAuth/OAuthScope'); -const AuthorizationCodeModule = require('../../../../../dist/connection/auth/DatabricksOAuth/AuthorizationCode'); +} = require('../../../../../lib/connection/auth/DatabricksOAuth/OAuthManager'); +const OAuthToken = require('../../../../../lib/connection/auth/DatabricksOAuth/OAuthToken').default; +const { OAuthScope, scopeDelimiter } = require('../../../../../lib/connection/auth/DatabricksOAuth/OAuthScope'); +const AuthorizationCodeModule = require('../../../../../lib/connection/auth/DatabricksOAuth/AuthorizationCode'); const { createValidAccessToken, createExpiredAccessToken } = require('./utils'); diff --git a/tests/unit/connection/auth/DatabricksOAuth/OAuthToken.test.js b/tests/unit/connection/auth/DatabricksOAuth/OAuthToken.test.js index 3e902051..6aaefea2 100644 --- a/tests/unit/connection/auth/DatabricksOAuth/OAuthToken.test.js +++ b/tests/unit/connection/auth/DatabricksOAuth/OAuthToken.test.js @@ -1,5 +1,5 @@ const { expect } = require('chai'); -const OAuthToken = require('../../../../../dist/connection/auth/DatabricksOAuth/OAuthToken').default; +const OAuthToken = require('../../../../../lib/connection/auth/DatabricksOAuth/OAuthToken').default; const { createAccessToken } = require('./utils'); diff --git a/tests/unit/connection/auth/DatabricksOAuth/index.test.js b/tests/unit/connection/auth/DatabricksOAuth/index.test.js index a2a06218..3b9e7b51 100644 --- a/tests/unit/connection/auth/DatabricksOAuth/index.test.js +++ b/tests/unit/connection/auth/DatabricksOAuth/index.test.js @@ -1,8 +1,8 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); -const DatabricksOAuth = require('../../../../../dist/connection/auth/DatabricksOAuth/index').default; -const OAuthToken = require('../../../../../dist/connection/auth/DatabricksOAuth/OAuthToken').default; -const OAuthManager = require('../../../../../dist/connection/auth/DatabricksOAuth/OAuthManager').default; +const DatabricksOAuth = require('../../../../../lib/connection/auth/DatabricksOAuth/index').default; +const OAuthToken = require('../../../../../lib/connection/auth/DatabricksOAuth/OAuthToken').default; +const OAuthManager = require('../../../../../lib/connection/auth/DatabricksOAuth/OAuthManager').default; const { createValidAccessToken, createExpiredAccessToken } = require('./utils'); diff --git a/tests/unit/connection/auth/PlainHttpAuthentication.test.js b/tests/unit/connection/auth/PlainHttpAuthentication.test.js index c799b071..cf4ba927 100644 --- a/tests/unit/connection/auth/PlainHttpAuthentication.test.js +++ b/tests/unit/connection/auth/PlainHttpAuthentication.test.js @@ -1,5 +1,5 @@ const { expect } = require('chai'); -const PlainHttpAuthentication = require('../../../../dist/connection/auth/PlainHttpAuthentication').default; +const PlainHttpAuthentication = require('../../../../lib/connection/auth/PlainHttpAuthentication').default; describe('PlainHttpAuthentication', () => { it('username and password must be anonymous if nothing passed', () => { diff --git a/tests/unit/connection/connections/HttpConnection.test.js b/tests/unit/connection/connections/HttpConnection.test.js index 261a3af8..cc1cfb85 100644 --- a/tests/unit/connection/connections/HttpConnection.test.js +++ b/tests/unit/connection/connections/HttpConnection.test.js @@ -1,8 +1,8 @@ const http = require('http'); const { expect } = require('chai'); -const HttpConnection = require('../../../../dist/connection/connections/HttpConnection').default; -const ThriftHttpConnection = require('../../../../dist/connection/connections/ThriftHttpConnection').default; -const DBSQLClient = require('../../../../dist/DBSQLClient').default; +const HttpConnection = require('../../../../lib/connection/connections/HttpConnection').default; +const ThriftHttpConnection = require('../../../../lib/connection/connections/ThriftHttpConnection').default; +const DBSQLClient = require('../../../../lib/DBSQLClient').default; describe('HttpConnection.connect', () => { it('should create Thrift connection', async () => { diff --git a/tests/unit/connection/connections/HttpRetryPolicy.test.js b/tests/unit/connection/connections/HttpRetryPolicy.test.js index 8c0e0a31..881a4869 100644 --- a/tests/unit/connection/connections/HttpRetryPolicy.test.js +++ b/tests/unit/connection/connections/HttpRetryPolicy.test.js @@ -1,9 +1,9 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); const { Request, Response } = require('node-fetch'); -const HttpRetryPolicy = require('../../../../dist/connection/connections/HttpRetryPolicy').default; -const { default: RetryError, RetryErrorCode } = require('../../../../dist/errors/RetryError'); -const DBSQLClient = require('../../../../dist/DBSQLClient').default; +const HttpRetryPolicy = require('../../../../lib/connection/connections/HttpRetryPolicy').default; +const { default: RetryError, RetryErrorCode } = require('../../../../lib/errors/RetryError'); +const DBSQLClient = require('../../../../lib/DBSQLClient').default; class ClientContextMock { constructor(configOverrides) { diff --git a/tests/unit/connection/connections/NullRetryPolicy.test.js b/tests/unit/connection/connections/NullRetryPolicy.test.js index f804e812..e0ad8b79 100644 --- a/tests/unit/connection/connections/NullRetryPolicy.test.js +++ b/tests/unit/connection/connections/NullRetryPolicy.test.js @@ -1,6 +1,6 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); -const NullRetryPolicy = require('../../../../dist/connection/connections/NullRetryPolicy').default; +const NullRetryPolicy = require('../../../../lib/connection/connections/NullRetryPolicy').default; describe('NullRetryPolicy', () => { it('should never allow retries', async () => { diff --git a/tests/unit/dto/InfoValue.test.js b/tests/unit/dto/InfoValue.test.js index a6f7a0b0..94e962c1 100644 --- a/tests/unit/dto/InfoValue.test.js +++ b/tests/unit/dto/InfoValue.test.js @@ -1,5 +1,5 @@ const { expect } = require('chai'); -const InfoValue = require('../../../dist/dto/InfoValue').default; +const InfoValue = require('../../../lib/dto/InfoValue').default; const NodeInt64 = require('node-int64'); const createInfoValueMock = (value) => diff --git a/tests/unit/dto/Status.test.js b/tests/unit/dto/Status.test.js index 63ad7ac9..e37c4645 100644 --- a/tests/unit/dto/Status.test.js +++ b/tests/unit/dto/Status.test.js @@ -1,6 +1,6 @@ const { expect } = require('chai'); -const { TCLIService_types } = require('../../../').thrift; -const Status = require('../../../dist/dto/Status').default; +const { TCLIService_types } = require('../../../lib').thrift; +const Status = require('../../../lib/dto/Status').default; describe('StatusFactory', () => { it('should be success', () => { diff --git a/tests/unit/hive/HiveDriver.test.js b/tests/unit/hive/HiveDriver.test.js index 254969f5..d2064880 100644 --- a/tests/unit/hive/HiveDriver.test.js +++ b/tests/unit/hive/HiveDriver.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); -const { TCLIService_types } = require('../../../').thrift; -const HiveDriver = require('../../../dist/hive/HiveDriver').default; +const { TCLIService_types } = require('../../../lib').thrift; +const HiveDriver = require('../../../lib/hive/HiveDriver').default; const toTitleCase = (str) => str[0].toUpperCase() + str.slice(1); diff --git a/tests/unit/hive/commands/BaseCommand.test.js b/tests/unit/hive/commands/BaseCommand.test.js index b7c8a48f..a21bd9cd 100644 --- a/tests/unit/hive/commands/BaseCommand.test.js +++ b/tests/unit/hive/commands/BaseCommand.test.js @@ -1,10 +1,10 @@ const { expect, AssertionError } = require('chai'); const { Request, Response } = require('node-fetch'); const { Thrift } = require('thrift'); -const HiveDriverError = require('../../../../dist/errors/HiveDriverError').default; -const BaseCommand = require('../../../../dist/hive/Commands/BaseCommand').default; -const HttpRetryPolicy = require('../../../../dist/connection/connections/HttpRetryPolicy').default; -const DBSQLClient = require('../../../../dist/DBSQLClient').default; +const HiveDriverError = require('../../../../lib/errors/HiveDriverError').default; +const BaseCommand = require('../../../../lib/hive/Commands/BaseCommand').default; +const HttpRetryPolicy = require('../../../../lib/connection/connections/HttpRetryPolicy').default; +const DBSQLClient = require('../../../../lib/DBSQLClient').default; class ThriftClientMock { constructor(context, methodHandler) { diff --git a/tests/unit/hive/commands/CancelDelegationTokenCommand.test.js b/tests/unit/hive/commands/CancelDelegationTokenCommand.test.js index 16804af4..cb14cc0c 100644 --- a/tests/unit/hive/commands/CancelDelegationTokenCommand.test.js +++ b/tests/unit/hive/commands/CancelDelegationTokenCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const CancelDelegationTokenCommand = require('../../../../dist/hive/Commands/CancelDelegationTokenCommand').default; +const CancelDelegationTokenCommand = require('../../../../lib/hive/Commands/CancelDelegationTokenCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/CancelOperationCommand.test.js b/tests/unit/hive/commands/CancelOperationCommand.test.js index c9d0faa1..94f06a50 100644 --- a/tests/unit/hive/commands/CancelOperationCommand.test.js +++ b/tests/unit/hive/commands/CancelOperationCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const CancelOperationCommand = require('../../../../dist/hive/Commands/CancelOperationCommand').default; +const CancelOperationCommand = require('../../../../lib/hive/Commands/CancelOperationCommand').default; const requestMock = { operationHandle: { diff --git a/tests/unit/hive/commands/CloseOperationCommand.test.js b/tests/unit/hive/commands/CloseOperationCommand.test.js index 5cba8946..79147844 100644 --- a/tests/unit/hive/commands/CloseOperationCommand.test.js +++ b/tests/unit/hive/commands/CloseOperationCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const CloseOperationCommand = require('../../../../dist/hive/Commands/CloseOperationCommand').default; +const CloseOperationCommand = require('../../../../lib/hive/Commands/CloseOperationCommand').default; const requestMock = { operationHandle: { diff --git a/tests/unit/hive/commands/CloseSessionCommand.test.js b/tests/unit/hive/commands/CloseSessionCommand.test.js index 76dd4a9b..6d15ed56 100644 --- a/tests/unit/hive/commands/CloseSessionCommand.test.js +++ b/tests/unit/hive/commands/CloseSessionCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const CloseSessionCommand = require('../../../../dist/hive/Commands/CloseSessionCommand').default; +const CloseSessionCommand = require('../../../../lib/hive/Commands/CloseSessionCommand').default; const responseMock = { status: { statusCode: 0 }, diff --git a/tests/unit/hive/commands/ExecuteStatementCommand.test.js b/tests/unit/hive/commands/ExecuteStatementCommand.test.js index 42150672..8e70337b 100644 --- a/tests/unit/hive/commands/ExecuteStatementCommand.test.js +++ b/tests/unit/hive/commands/ExecuteStatementCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const ExecuteStatementCommand = require('../../../../dist/hive/Commands/ExecuteStatementCommand').default; +const ExecuteStatementCommand = require('../../../../lib/hive/Commands/ExecuteStatementCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/FetchResultsCommand.test.js b/tests/unit/hive/commands/FetchResultsCommand.test.js index 5423fc81..021c0c18 100644 --- a/tests/unit/hive/commands/FetchResultsCommand.test.js +++ b/tests/unit/hive/commands/FetchResultsCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const FetchResultsCommand = require('../../../../dist/hive/Commands/FetchResultsCommand').default; +const FetchResultsCommand = require('../../../../lib/hive/Commands/FetchResultsCommand').default; const requestMock = { operationHandle: { diff --git a/tests/unit/hive/commands/GetCatalogsCommand.test.js b/tests/unit/hive/commands/GetCatalogsCommand.test.js index 0178d1b5..7c57e661 100644 --- a/tests/unit/hive/commands/GetCatalogsCommand.test.js +++ b/tests/unit/hive/commands/GetCatalogsCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetCatalogsCommand = require('../../../../dist/hive/Commands/GetCatalogsCommand').default; +const GetCatalogsCommand = require('../../../../lib/hive/Commands/GetCatalogsCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetColumnsCommand.test.js b/tests/unit/hive/commands/GetColumnsCommand.test.js index f16d143f..062f420b 100644 --- a/tests/unit/hive/commands/GetColumnsCommand.test.js +++ b/tests/unit/hive/commands/GetColumnsCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetColumnsCommand = require('../../../../dist/hive/Commands/GetColumnsCommand').default; +const GetColumnsCommand = require('../../../../lib/hive/Commands/GetColumnsCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetCrossReferenceCommand.test.js b/tests/unit/hive/commands/GetCrossReferenceCommand.test.js index 25f8c97a..99ca435e 100644 --- a/tests/unit/hive/commands/GetCrossReferenceCommand.test.js +++ b/tests/unit/hive/commands/GetCrossReferenceCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetCrossReferenceCommand = require('../../../../dist/hive/Commands/GetCrossReferenceCommand').default; +const GetCrossReferenceCommand = require('../../../../lib/hive/Commands/GetCrossReferenceCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetDelegationTokenCommand.test.js b/tests/unit/hive/commands/GetDelegationTokenCommand.test.js index eb419e89..9f715f5d 100644 --- a/tests/unit/hive/commands/GetDelegationTokenCommand.test.js +++ b/tests/unit/hive/commands/GetDelegationTokenCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetDelegationTokenCommand = require('../../../../dist/hive/Commands/GetDelegationTokenCommand').default; +const GetDelegationTokenCommand = require('../../../../lib/hive/Commands/GetDelegationTokenCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetFunctionsCommand.test.js b/tests/unit/hive/commands/GetFunctionsCommand.test.js index f7cfe75b..07a37a58 100644 --- a/tests/unit/hive/commands/GetFunctionsCommand.test.js +++ b/tests/unit/hive/commands/GetFunctionsCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetFunctionsCommand = require('../../../../dist/hive/Commands/GetFunctionsCommand').default; +const GetFunctionsCommand = require('../../../../lib/hive/Commands/GetFunctionsCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetInfoCommand.test.js b/tests/unit/hive/commands/GetInfoCommand.test.js index 8fc073bd..1ceaa711 100644 --- a/tests/unit/hive/commands/GetInfoCommand.test.js +++ b/tests/unit/hive/commands/GetInfoCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetInfoCommand = require('../../../../dist/hive/Commands/GetInfoCommand').default; +const GetInfoCommand = require('../../../../lib/hive/Commands/GetInfoCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetOperationStatusCommand.test.js b/tests/unit/hive/commands/GetOperationStatusCommand.test.js index eb0881c3..d84aae05 100644 --- a/tests/unit/hive/commands/GetOperationStatusCommand.test.js +++ b/tests/unit/hive/commands/GetOperationStatusCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetOperationStatusCommand = require('../../../../dist/hive/Commands/GetOperationStatusCommand').default; +const GetOperationStatusCommand = require('../../../../lib/hive/Commands/GetOperationStatusCommand').default; const requestMock = { operationHandle: { diff --git a/tests/unit/hive/commands/GetPrimaryKeysCommand.test.js b/tests/unit/hive/commands/GetPrimaryKeysCommand.test.js index e2ed8e57..f3044454 100644 --- a/tests/unit/hive/commands/GetPrimaryKeysCommand.test.js +++ b/tests/unit/hive/commands/GetPrimaryKeysCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetPrimaryKeysCommand = require('../../../../dist/hive/Commands/GetPrimaryKeysCommand').default; +const GetPrimaryKeysCommand = require('../../../../lib/hive/Commands/GetPrimaryKeysCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetResultSetMetadataCommand.test.js b/tests/unit/hive/commands/GetResultSetMetadataCommand.test.js index 89217de4..b426acc7 100644 --- a/tests/unit/hive/commands/GetResultSetMetadataCommand.test.js +++ b/tests/unit/hive/commands/GetResultSetMetadataCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetResultSetMetadataCommand = require('../../../../dist/hive/Commands/GetResultSetMetadataCommand').default; +const GetResultSetMetadataCommand = require('../../../../lib/hive/Commands/GetResultSetMetadataCommand').default; const requestMock = { operationHandle: { diff --git a/tests/unit/hive/commands/GetSchemasCommand.test.js b/tests/unit/hive/commands/GetSchemasCommand.test.js index 4ba62a6f..5fc5122e 100644 --- a/tests/unit/hive/commands/GetSchemasCommand.test.js +++ b/tests/unit/hive/commands/GetSchemasCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetSchemasCommand = require('../../../../dist/hive/Commands/GetSchemasCommand').default; +const GetSchemasCommand = require('../../../../lib/hive/Commands/GetSchemasCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetTableTypesCommand.test.js b/tests/unit/hive/commands/GetTableTypesCommand.test.js index bee9ab92..02601515 100644 --- a/tests/unit/hive/commands/GetTableTypesCommand.test.js +++ b/tests/unit/hive/commands/GetTableTypesCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetTableTypesCommand = require('../../../../dist/hive/Commands/GetTableTypesCommand').default; +const GetTableTypesCommand = require('../../../../lib/hive/Commands/GetTableTypesCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetTablesCommand.test.js b/tests/unit/hive/commands/GetTablesCommand.test.js index c24dd0d8..994c5030 100644 --- a/tests/unit/hive/commands/GetTablesCommand.test.js +++ b/tests/unit/hive/commands/GetTablesCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetTablesCommand = require('../../../../dist/hive/Commands/GetTablesCommand').default; +const GetTablesCommand = require('../../../../lib/hive/Commands/GetTablesCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/GetTypeInfoCommand.test.js b/tests/unit/hive/commands/GetTypeInfoCommand.test.js index c899e042..0bd9dbdc 100644 --- a/tests/unit/hive/commands/GetTypeInfoCommand.test.js +++ b/tests/unit/hive/commands/GetTypeInfoCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const GetTypeInfoCommand = require('../../../../dist/hive/Commands/GetTypeInfoCommand').default; +const GetTypeInfoCommand = require('../../../../lib/hive/Commands/GetTypeInfoCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/hive/commands/OpenSessionCommand.test.js b/tests/unit/hive/commands/OpenSessionCommand.test.js index 034ab278..af3a5800 100644 --- a/tests/unit/hive/commands/OpenSessionCommand.test.js +++ b/tests/unit/hive/commands/OpenSessionCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const OpenSessionCommand = require('../../../../dist/hive/Commands/OpenSessionCommand').default; +const OpenSessionCommand = require('../../../../lib/hive/Commands/OpenSessionCommand').default; const CLIENT_PROTOCOL = 8; diff --git a/tests/unit/hive/commands/RenewDelegationTokenCommand.test.js b/tests/unit/hive/commands/RenewDelegationTokenCommand.test.js index b4363caa..12b44e0a 100644 --- a/tests/unit/hive/commands/RenewDelegationTokenCommand.test.js +++ b/tests/unit/hive/commands/RenewDelegationTokenCommand.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const sinon = require('sinon'); const TCLIService_types = require('../../../../thrift/TCLIService_types'); -const RenewDelegationTokenCommand = require('../../../../dist/hive/Commands/RenewDelegationTokenCommand').default; +const RenewDelegationTokenCommand = require('../../../../lib/hive/Commands/RenewDelegationTokenCommand').default; const requestMock = { sessionHandle: { diff --git a/tests/unit/polyfills.test.js b/tests/unit/polyfills.test.js index a1e392d9..80571966 100644 --- a/tests/unit/polyfills.test.js +++ b/tests/unit/polyfills.test.js @@ -1,5 +1,5 @@ const { expect } = require('chai'); -const { at } = require('../../dist/polyfills'); +const { at } = require('../../lib/polyfills'); const defaultArrayMock = { 0: 'a', diff --git a/tests/unit/result/ArrowResultConverter.test.js b/tests/unit/result/ArrowResultConverter.test.js index 4b53c620..8ac2e1dd 100644 --- a/tests/unit/result/ArrowResultConverter.test.js +++ b/tests/unit/result/ArrowResultConverter.test.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const fs = require('fs'); const path = require('path'); const { tableFromArrays, tableToIPC, Table } = require('apache-arrow'); -const ArrowResultConverter = require('../../../dist/result/ArrowResultConverter').default; +const ArrowResultConverter = require('../../../lib/result/ArrowResultConverter').default; const ResultsProviderMock = require('./fixtures/ResultsProviderMock'); function createSampleThriftSchema(columnName) { diff --git a/tests/unit/result/ArrowResultHandler.test.js b/tests/unit/result/ArrowResultHandler.test.js index 92cb573d..b6852deb 100644 --- a/tests/unit/result/ArrowResultHandler.test.js +++ b/tests/unit/result/ArrowResultHandler.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const Int64 = require('node-int64'); const LZ4 = require('lz4'); -const ArrowResultHandler = require('../../../dist/result/ArrowResultHandler').default; +const ArrowResultHandler = require('../../../lib/result/ArrowResultHandler').default; const ResultsProviderMock = require('./fixtures/ResultsProviderMock'); const sampleArrowSchema = Buffer.from([ diff --git a/tests/unit/result/CloudFetchResultHandler.test.js b/tests/unit/result/CloudFetchResultHandler.test.js index d2899ccd..e7e19eab 100644 --- a/tests/unit/result/CloudFetchResultHandler.test.js +++ b/tests/unit/result/CloudFetchResultHandler.test.js @@ -2,9 +2,9 @@ const { expect, AssertionError } = require('chai'); const sinon = require('sinon'); const Int64 = require('node-int64'); const LZ4 = require('lz4'); -const CloudFetchResultHandler = require('../../../dist/result/CloudFetchResultHandler').default; +const CloudFetchResultHandler = require('../../../lib/result/CloudFetchResultHandler').default; const ResultsProviderMock = require('./fixtures/ResultsProviderMock'); -const DBSQLClient = require('../../../dist/DBSQLClient').default; +const DBSQLClient = require('../../../lib/DBSQLClient').default; const sampleArrowSchema = Buffer.from([ 255, 255, 255, 255, 208, 0, 0, 0, 16, 0, 0, 0, 0, 0, 10, 0, 14, 0, 6, 0, 13, 0, 8, 0, 10, 0, 0, 0, 0, 0, 4, 0, 16, 0, diff --git a/tests/unit/result/JsonResultHandler.test.js b/tests/unit/result/JsonResultHandler.test.js index 4c85147b..5cef3ac9 100644 --- a/tests/unit/result/JsonResultHandler.test.js +++ b/tests/unit/result/JsonResultHandler.test.js @@ -1,6 +1,6 @@ const { expect } = require('chai'); -const JsonResultHandler = require('../../../dist/result/JsonResultHandler').default; -const { TCLIService_types } = require('../../../').thrift; +const JsonResultHandler = require('../../../lib/result/JsonResultHandler').default; +const { TCLIService_types } = require('../../../lib').thrift; const Int64 = require('node-int64'); const ResultsProviderMock = require('./fixtures/ResultsProviderMock'); diff --git a/tests/unit/result/ResultSlicer.test.js b/tests/unit/result/ResultSlicer.test.js index 715d250b..e00615d9 100644 --- a/tests/unit/result/ResultSlicer.test.js +++ b/tests/unit/result/ResultSlicer.test.js @@ -1,6 +1,6 @@ const { expect } = require('chai'); const sinon = require('sinon'); -const ResultSlicer = require('../../../dist/result/ResultSlicer').default; +const ResultSlicer = require('../../../lib/result/ResultSlicer').default; const ResultsProviderMock = require('./fixtures/ResultsProviderMock'); describe('ResultSlicer', () => { diff --git a/tests/unit/result/compatibility.test.js b/tests/unit/result/compatibility.test.js index 1fe22cbd..b232aa49 100644 --- a/tests/unit/result/compatibility.test.js +++ b/tests/unit/result/compatibility.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); -const ArrowResultHandler = require('../../../dist/result/ArrowResultHandler').default; -const ArrowResultConverter = require('../../../dist/result/ArrowResultConverter').default; -const JsonResultHandler = require('../../../dist/result/JsonResultHandler').default; +const ArrowResultHandler = require('../../../lib/result/ArrowResultHandler').default; +const ArrowResultConverter = require('../../../lib/result/ArrowResultConverter').default; +const JsonResultHandler = require('../../../lib/result/JsonResultHandler').default; const { fixArrowResult } = require('../../fixtures/compatibility'); const fixtureColumn = require('../../fixtures/compatibility/column'); diff --git a/tests/unit/result/utils.test.js b/tests/unit/result/utils.test.js index 9939b141..52604ca2 100644 --- a/tests/unit/result/utils.test.js +++ b/tests/unit/result/utils.test.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const Int64 = require('node-int64'); -const { TCLIService_types } = require('../../../').thrift; -const { getSchemaColumns, convertThriftValue } = require('../../../dist/result/utils'); +const { TCLIService_types } = require('../../../lib').thrift; +const { getSchemaColumns, convertThriftValue } = require('../../../lib/result/utils'); const { TTypeId } = TCLIService_types; diff --git a/tests/unit/utils/CloseableCollection.test.js b/tests/unit/utils/CloseableCollection.test.js index 8056dba4..3a167cf1 100644 --- a/tests/unit/utils/CloseableCollection.test.js +++ b/tests/unit/utils/CloseableCollection.test.js @@ -1,5 +1,5 @@ const { expect, AssertionError } = require('chai'); -const CloseableCollection = require('../../../dist/utils/CloseableCollection').default; +const CloseableCollection = require('../../../lib/utils/CloseableCollection').default; describe('CloseableCollection', () => { it('should add item if not already added', () => {