@@ -40,13 +40,14 @@ import { v4 as uuidv4 } from 'uuid';
4040import {
4141 TGetOperationStatusResp ,
4242 TGetResultSetMetadataResp ,
43- TOperationState ,
4443 TSparkRowSetType ,
4544 TStatusCode ,
4645 TTableSchema ,
4746} from '../../thrift/TCLIService_types' ;
4847import IOperationBackend from '../contracts/IOperationBackend' ;
4948import IClientContext from '../contracts/IClientContext' ;
49+ import { OperationState , OperationStatus } from '../contracts/OperationStatus' ;
50+ import { ResultFormat , ResultMetadata } from '../contracts/ResultMetadata' ;
5051import Status from '../dto/Status' ;
5152import ArrowResultConverter from '../result/ArrowResultConverter' ;
5253import ResultSlicer from '../result/ResultSlicer' ;
@@ -148,7 +149,17 @@ export default class SeaOperationBackend implements IOperationBackend {
148149 return slicer . hasMore ( ) ;
149150 }
150151
151- public async getResultMetadata ( ) : Promise < TGetResultSetMetadataResp > {
152+ public async getResultMetadata ( ) : Promise < ResultMetadata > {
153+ const metadata = await this . thriftResultMetadataResponse ( ) ;
154+ return {
155+ schema : metadata . schema ,
156+ resultFormat : ResultFormat . ArrowBased ,
157+ lz4Compressed : metadata . lz4Compressed ,
158+ isStagingOperation : Boolean ( metadata . isStagingOperation ) ,
159+ } ;
160+ }
161+
162+ private async thriftResultMetadataResponse ( ) : Promise < TGetResultSetMetadataResp > {
152163 failIfNotActive ( this . lifecycle ) ;
153164 if ( this . metadata ) {
154165 return this . metadata ;
@@ -187,28 +198,25 @@ export default class SeaOperationBackend implements IOperationBackend {
187198 // Status / lifecycle (owned by the sea-operation lifecycle helpers).
188199 // ---------------------------------------------------------------------------
189200
190- public async status ( _progress : boolean ) : Promise < TGetOperationStatusResp > {
201+ public async status ( _progress : boolean ) : Promise < OperationStatus > {
191202 // Synthesised — kernel only surfaces terminal-or-running statements
192203 // through its public API; we report CANCELED/CLOSED if the lifecycle
193204 // flag is set, else FINISHED. Matches the Thrift status shape so
194205 // facade-level callers see consistent telemetry across backends.
195206 if ( this . lifecycle . isCancelled ) {
196207 return {
197- status : { statusCode : TStatusCode . SUCCESS_STATUS } ,
198- operationState : TOperationState . CANCELED_STATE ,
208+ state : OperationState . Cancelled ,
199209 hasResultSet : true ,
200210 } ;
201211 }
202212 if ( this . lifecycle . isClosed ) {
203213 return {
204- status : { statusCode : TStatusCode . SUCCESS_STATUS } ,
205- operationState : TOperationState . CLOSED_STATE ,
214+ state : OperationState . Closed ,
206215 hasResultSet : true ,
207216 } ;
208217 }
209218 return {
210- status : { statusCode : TStatusCode . SUCCESS_STATUS } ,
211- operationState : TOperationState . FINISHED_STATE ,
219+ state : OperationState . Succeeded ,
212220 hasResultSet : true ,
213221 } ;
214222 }
@@ -245,7 +253,7 @@ export default class SeaOperationBackend implements IOperationBackend {
245253 if ( ! this . statement . fetchNextBatch ) {
246254 throw new Error ( 'SeaOperationBackend: statement.fetchNextBatch() is not available on this handle' ) ;
247255 }
248- const metadata = await this . getResultMetadata ( ) ;
256+ const metadata = await this . thriftResultMetadataResponse ( ) ;
249257 // The lifecycle subset has cancel/close only; fetch methods exist on
250258 // the full napi Statement. Cast is safe here because we've just
251259 // verified `fetchNextBatch` is callable.
0 commit comments