Skip to content

Commit

Permalink
Merge pull request #57 from lenchv/patch/#53-add-orientation-paramter
Browse files Browse the repository at this point in the history
add orientation parameter to fetchAll to force first phase fetching o…
  • Loading branch information
lenchv authored Sep 25, 2023
2 parents ab411e5 + 1d9b835 commit fd86564
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 24 deletions.
4 changes: 2 additions & 2 deletions dist/HiveOperation.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import IOperation from "./contracts/IOperation";
import HiveDriver from "./hive/HiveDriver";
import { OperationHandle, TCLIServiceTypes, TableSchema, RowSet } from "./hive/Types";
import { OperationHandle, TCLIServiceTypes, TableSchema, RowSet, FetchOrientation } from "./hive/Types";
import Status from "./dto/Status";
import { GetOperationStatusResponse } from "./hive/Commands/GetOperationStatusCommand";
export default class HiveOperation implements IOperation {
Expand All @@ -20,7 +20,7 @@ export default class HiveOperation implements IOperation {
* Fetches result and schema from operation
* @throws {StatusError}
*/
fetch(): Promise<Status>;
fetch(orientation?: FetchOrientation): Promise<Status>;
/**
* Requests operation status
* @param progress
Expand Down
9 changes: 7 additions & 2 deletions dist/HiveOperation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/HiveOperation.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/contracts/IOperation.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { GetOperationStatusResponse } from "../hive/Commands/GetOperationStatusCommand";
import Status from "../dto/Status";
import { TableSchema, RowSet } from "../hive/Types";
import { TableSchema, RowSet, FetchOrientation } from "../hive/Types";
export default interface IOperation {
/**
* Fetch schema and a portion of data
*/
fetch(): Promise<Status>;
fetch(orientation?: FetchOrientation): Promise<Status>;
/**
* Request status of operation
*
Expand Down
4 changes: 4 additions & 0 deletions dist/hive/Types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,8 @@ export type ProgressUpdateResponse = {
footerSummary: string;
startTime: ThriftBuffer;
};
export declare enum FetchOrientation {
FETCH_FIRST = 0,
FETCH_NEXT = 1
}
export {};
7 changes: 6 additions & 1 deletion dist/hive/Types/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/hive/Types/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/utils/HiveUtils.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { TCLIServiceTypes, ProgressUpdateResponse } from "../hive/Types";
import { TCLIServiceTypes, ProgressUpdateResponse, FetchOrientation } from "../hive/Types";
import IOperation from "../contracts/IOperation";
import IOperationResult from "../result/IOperationResult";
export default class HiveUtils {
private TCLIService_types;
constructor(TCLIService_types: TCLIServiceTypes);
waitUntilReady(operation: IOperation, progress?: boolean, callback?: Function): Promise<IOperation>;
getResult(operation: IOperation, resultHandler?: IOperationResult): IOperationResult;
fetchAll(operation: IOperation): Promise<IOperation>;
fetchAll(operation: IOperation, orientation?: FetchOrientation): Promise<IOperation>;
formatProgress(progressUpdate: ProgressUpdateResponse): string;
}
4 changes: 2 additions & 2 deletions dist/utils/HiveUtils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/utils/HiveUtils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions lib/HiveOperation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import IOperation from "./contracts/IOperation";
import HiveDriver from "./hive/HiveDriver";
import { OperationHandle, TCLIServiceTypes, TableSchema, RowSet, ColumnCode, Column } from "./hive/Types";
import { OperationHandle, TCLIServiceTypes, TableSchema, RowSet, ColumnCode, Column, FetchOrientation } from "./hive/Types";
import Status from "./dto/Status";
import { GetOperationStatusResponse } from "./hive/Commands/GetOperationStatusCommand";
import { GetResultSetMetadataResponse } from "./hive/Commands/GetResultSetMetadataCommand";
Expand Down Expand Up @@ -43,7 +43,7 @@ export default class HiveOperation implements IOperation {
* Fetches result and schema from operation
* @throws {StatusError}
*/
fetch(): Promise<Status> {
fetch(orientation?: FetchOrientation): Promise<Status> {
if (!this.hasResultSet) {
return Promise.resolve(
this.statusFactory.create({
Expand All @@ -63,8 +63,12 @@ export default class HiveOperation implements IOperation {
if (this.schema === null) {
return this.initializeSchema().then((schema: TableSchema) => {
this.schema = schema;

return this.firstFetch();

if (orientation === FetchOrientation.FETCH_NEXT) {
return this.nextFetch();
} else {
return this.firstFetch();
}
}).then(
response => this.processFetchResponse(response)
);
Expand Down
4 changes: 2 additions & 2 deletions lib/contracts/IOperation.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { GetOperationStatusResponse } from "../hive/Commands/GetOperationStatusCommand";
import Status from "../dto/Status";
import { TableSchema, RowSet } from "../hive/Types";
import { TableSchema, RowSet, FetchOrientation } from "../hive/Types";

export default interface IOperation {
/**
* Fetch schema and a portion of data
*/
fetch(): Promise<Status>;
fetch(orientation?: FetchOrientation): Promise<Status>;

/**
* Request status of operation
Expand Down
5 changes: 5 additions & 0 deletions lib/hive/Types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,8 @@ export type ProgressUpdateResponse = {
footerSummary: string,
startTime: ThriftBuffer
};

export enum FetchOrientation {
FETCH_FIRST,
FETCH_NEXT,
}
Loading

0 comments on commit fd86564

Please sign in to comment.