import { Readable } from 'node:stream'; import IOperation, { FetchOptions, FinishedOptions, GetSchemaOptions, IteratorOptions, IOperationChunksIterator, IOperationRowsIterator, NodeStreamOptions } from './contracts/IOperation'; import { TGetOperationStatusResp, TGetResultSetMetadataResp, TTableSchema } from '../thrift/TCLIService_types'; import Status from './dto/Status'; import IClientContext from './contracts/IClientContext'; import IOperationBackend from './contracts/IOperationBackend'; import { ResultMetadata } from './contracts/ResultMetadata'; interface DBSQLOperationConstructorOptions { backend: IOperationBackend; context: IClientContext; sessionId?: string; } export default class DBSQLOperation implements IOperation { private readonly context; private readonly backend; onClose?: () => void; private closed; private cancelled; readonly _data?: unknown; private metadata?; private startTime; private pollCount; private sessionId?; constructor(options: DBSQLOperationConstructorOptions); get id(): string; iterateChunks(options?: IteratorOptions): IOperationChunksIterator; iterateRows(options?: IteratorOptions): IOperationRowsIterator; toNodeStream(options?: NodeStreamOptions): Readable; /** * Fetches all data * @public * @param options - maxRows property can be set to limit chunk size * @returns Array of data with length equal to option.maxRows * @throws {StatusError} * @example * const result = await queryOperation.fetchAll(); */ fetchAll(options?: FetchOptions): Promise>; /** * Fetches chunk of data * @public * @param options - maxRows property sets chunk size * @returns Array of data with length equal to option.maxRows * @throws {StatusError} * @example * const result = await queryOperation.fetchChunk({maxRows: 1000}); */ fetchChunk(options?: FetchOptions): Promise>; private fetchChunkInternal; /** * Requests operation status. Returns the Thrift wire response for * back-compat with existing user code. On the Thrift backend the response * is returned verbatim; on any other backend (e.g. kernel) the response is * synthesized from the neutral {@link IOperationBackend.status} result, * with Thrift-only fields (`taskStatus`, `numModifiedRows`, etc.) left * undefined. * * @param progress * @throws {StatusError} */ status(progress?: boolean): Promise; /** * Cancels operation * @throws {StatusError} */ cancel(): Promise; private cancelInternal; /** * Closes operation * @throws {StatusError} */ close(): Promise; private closeInternal; finished(options?: FinishedOptions): Promise; hasMoreRows(): Promise; getSchema(options?: GetSchemaOptions): Promise; /** * Thrift-only compatibility hook used by existing e2e tests to assert the * concrete result handler selected for a result format. * * Not part of the public `IOperation` contract. */ getResultHandler(): Promise; getResultMetadata(): Promise; /** * Fetch result-set metadata as the Thrift wire response. Kept for * back-compat with existing user code. On the Thrift backend the wire * response is returned verbatim; on any other backend the response is * synthesized from the neutral {@link ResultMetadata}, with Thrift-only * fields (`cacheLookupResult`, `uncompressedBytes`, `compressedBytes`, * `status`) left undefined / defaulted. * * @deprecated Use {@link DBSQLOperation.getResultMetadata}; this method * synthesizes Thrift-only fields as `undefined` on non-Thrift backends and * couples callers to the Thrift wire shape. */ getMetadata(): Promise; /** * Wrap a public IOperation method so any thrown error is captured as an * error telemetry event before being rethrown to the caller. Telemetry * never alters the throw semantics. */ private withErrorTelemetry; private failIfClosed; private waitUntilReadyThroughBackend; /** * Emit statement.start telemetry event. * CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY. */ private emitStatementStart; /** * Emit statement.complete telemetry event and complete aggregation. * CRITICAL: All exceptions swallowed and logged at LogLevel.debug ONLY. */ private emitStatementComplete; /** * Emit a telemetry error event for an exception thrown by an operation. * Terminal errors (per `ExceptionClassifier`) trigger an immediate flush * in the aggregator; retryable errors are buffered until the statement * completes. All exceptions from this method itself are swallowed at * debug level — telemetry must never break the driver. */ private emitErrorEvent; } export {};