Skip to content

Commit 0e802ec

Browse files
committed
Fix SEA abstraction merge fallout
Restore Thrift compatibility paths needed by existing schema and result-handler tests after merging main telemetry changes. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
1 parent 45563e5 commit 0e802ec

6 files changed

Lines changed: 31 additions & 29 deletions

File tree

lib/DBSQLOperation.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ import IOperation, {
99
IOperationRowsIterator,
1010
NodeStreamOptions,
1111
} from './contracts/IOperation';
12-
import {
13-
TGetOperationStatusResp,
14-
TGetResultSetMetadataResp,
15-
TTableSchema,
16-
} from '../thrift/TCLIService_types';
12+
import { TGetOperationStatusResp, TGetResultSetMetadataResp, TTableSchema } from '../thrift/TCLIService_types';
1713
import Status from './dto/Status';
1814
import { LogLevel } from './contracts/IDBSQLLogger';
1915
import OperationStateError, { OperationStateErrorCode } from './errors/OperationStateError';
@@ -270,11 +266,28 @@ export default class DBSQLOperation implements IOperation {
270266
await this.waitUntilReadyThroughBackend(options);
271267

272268
this.context.getLogger().log(LogLevel.debug, `Fetching schema for operation with id: ${this.id}`);
269+
if (this.backend instanceof ThriftOperationBackend) {
270+
const metadata = await this.backend.thriftResultMetadataResponse();
271+
return metadata.schema ?? null;
272+
}
273273
const metadata = await this.getResultMetadata();
274274
return metadata.schema ?? null;
275275
});
276276
}
277277

278+
/**
279+
* Thrift-only compatibility hook used by existing e2e tests to assert the
280+
* concrete result handler selected for a result format.
281+
*
282+
* Not part of the public `IOperation` contract.
283+
*/
284+
public async getResultHandler(): Promise<unknown> {
285+
if (this.backend instanceof ThriftOperationBackend) {
286+
return this.backend.getResultHandler();
287+
}
288+
throw new Error('DBSQLOperation.getResultHandler is only available for the Thrift backend');
289+
}
290+
278291
public async getResultMetadata(): Promise<ResultMetadata> {
279292
await this.failIfClosed();
280293
await this.waitUntilReadyThroughBackend();

lib/contracts/IOperationBackend.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ export default interface IOperationBackend {
6161
* returning `[]` is the correct way to bail — the user-visible error is
6262
* still raised by the facade.
6363
*/
64-
fetchChunk(options: {
65-
limit: number;
66-
disableBuffering?: boolean;
67-
isClosed?: () => boolean;
68-
}): Promise<Array<object>>;
64+
fetchChunk(options: { limit: number; disableBuffering?: boolean; isClosed?: () => boolean }): Promise<Array<object>>;
6965

7066
/** Whether more rows are available beyond what has been fetched. */
7167
hasMore(): Promise<boolean>;

lib/thrift-backend/ThriftOperationBackend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export default class ThriftOperationBackend implements IOperationBackend {
314314
return new Status(response.status);
315315
}
316316

317-
private async getResultHandler(): Promise<ResultSlicer<any>> {
317+
public async getResultHandler(): Promise<ResultSlicer<any>> {
318318
const metadata = await this.thriftResultMetadataResponse();
319319
const resultFormat = definedOrError(metadata.resultFormat);
320320

tests/unit/.stubs/createOperationForTest.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ interface CreateOperationForTestArgs {
1515
* shape by constructing a `ThriftOperationBackend` explicitly. Keeps the
1616
* facade decoupled from concrete backend imports.
1717
*/
18-
export function createOperationForTest({
19-
handle,
20-
directResults,
21-
context,
22-
}: CreateOperationForTestArgs): DBSQLOperation {
18+
export function createOperationForTest({ handle, directResults, context }: CreateOperationForTestArgs): DBSQLOperation {
2319
const backend = new ThriftOperationBackend({ handle, directResults, context });
2420
return new DBSQLOperation({ backend, context });
2521
}

tests/unit/.stubs/createSessionForTest.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ interface CreateSessionForTestArgs {
1515
* shape by constructing a `ThriftSessionBackend` explicitly. Keeps the
1616
* facade decoupled from concrete backend imports.
1717
*/
18-
export function createSessionForTest({ handle, context, serverProtocolVersion }: CreateSessionForTestArgs): DBSQLSession {
18+
export function createSessionForTest({
19+
handle,
20+
context,
21+
serverProtocolVersion,
22+
}: CreateSessionForTestArgs): DBSQLSession {
1923
const backend = new ThriftSessionBackend({ handle, context, serverProtocolVersion });
2024
return new DBSQLSession({ backend, context });
2125
}

tests/unit/thrift-backend/wireSynthesis.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
import { expect } from 'chai';
2-
import {
3-
TOperationState,
4-
TSparkRowSetType,
5-
TStatusCode,
6-
} from '../../../thrift/TCLIService_types';
2+
import { TOperationState, TSparkRowSetType, TStatusCode } from '../../../thrift/TCLIService_types';
73
import { OperationState, OperationStatus } from '../../../lib/contracts/OperationStatus';
84
import { ResultFormat, ResultMetadata } from '../../../lib/contracts/ResultMetadata';
9-
import {
10-
synthesizeThriftStatus,
11-
synthesizeThriftResultSetMetadata,
12-
} from '../../../lib/thrift-backend/wireSynthesis';
5+
import { synthesizeThriftStatus, synthesizeThriftResultSetMetadata } from '../../../lib/thrift-backend/wireSynthesis';
136
import HiveDriverError from '../../../lib/errors/HiveDriverError';
147

158
describe('wireSynthesis', () => {
@@ -90,9 +83,9 @@ describe('wireSynthesis', () => {
9083
expect(
9184
synthesizeThriftResultSetMetadata({ ...base, resultFormat: ResultFormat.ArrowBased }).resultFormat,
9285
).to.equal(TSparkRowSetType.ARROW_BASED_SET);
93-
expect(
94-
synthesizeThriftResultSetMetadata({ ...base, resultFormat: ResultFormat.UrlBased }).resultFormat,
95-
).to.equal(TSparkRowSetType.URL_BASED_SET);
86+
expect(synthesizeThriftResultSetMetadata({ ...base, resultFormat: ResultFormat.UrlBased }).resultFormat).to.equal(
87+
TSparkRowSetType.URL_BASED_SET,
88+
);
9689
});
9790

9891
it('throws HiveDriverError on an unknown ResultFormat instead of silently aliasing', () => {

0 commit comments

Comments
 (0)