Skip to content

Commit 658870f

Browse files
samikshya-dbclaude
andcommitted
Map Thrift operation type to proto Operation.Type enum
- Convert TOperationType (Thrift) to proto Operation.Type names - EXECUTE_STATEMENT remains EXECUTE_STATEMENT - GET_TYPE_INFO -> LIST_TYPE_INFO - GET_CATALOGS -> LIST_CATALOGS - GET_SCHEMAS -> LIST_SCHEMAS - GET_TABLES -> LIST_TABLES - GET_TABLE_TYPES -> LIST_TABLE_TYPES - GET_COLUMNS -> LIST_COLUMNS - GET_FUNCTIONS -> LIST_FUNCTIONS - UNKNOWN -> TYPE_UNSPECIFIED Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 42f1e23 commit 658870f

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

lib/DBSQLOperation.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import IOperation, {
1313
import {
1414
TGetOperationStatusResp,
1515
TOperationHandle,
16+
TOperationType,
1617
TTableSchema,
1718
TSparkDirectResults,
1819
TGetResultSetMetadataResp,
@@ -51,6 +52,38 @@ async function delay(ms?: number): Promise<void> {
5152
});
5253
}
5354

55+
/**
56+
* Map Thrift TOperationType to proto Operation.Type enum string.
57+
* Proto values: EXECUTE_STATEMENT=3, LIST_TYPE_INFO=7, LIST_CATALOGS=8, etc.
58+
*/
59+
function mapOperationTypeToProto(operationType?: TOperationType): string | undefined {
60+
if (operationType === undefined) {
61+
return undefined;
62+
}
63+
64+
switch (operationType) {
65+
case TOperationType.EXECUTE_STATEMENT:
66+
return 'EXECUTE_STATEMENT';
67+
case TOperationType.GET_TYPE_INFO:
68+
return 'LIST_TYPE_INFO';
69+
case TOperationType.GET_CATALOGS:
70+
return 'LIST_CATALOGS';
71+
case TOperationType.GET_SCHEMAS:
72+
return 'LIST_SCHEMAS';
73+
case TOperationType.GET_TABLES:
74+
return 'LIST_TABLES';
75+
case TOperationType.GET_TABLE_TYPES:
76+
return 'LIST_TABLE_TYPES';
77+
case TOperationType.GET_COLUMNS:
78+
return 'LIST_COLUMNS';
79+
case TOperationType.GET_FUNCTIONS:
80+
return 'LIST_FUNCTIONS';
81+
case TOperationType.UNKNOWN:
82+
default:
83+
return 'TYPE_UNSPECIFIED';
84+
}
85+
}
86+
5487
export default class DBSQLOperation implements IOperation {
5588
private readonly context: IClientContext;
5689

@@ -515,7 +548,7 @@ export default class DBSQLOperation implements IOperation {
515548
telemetryEmitter.emitStatementStart({
516549
statementId: this.id,
517550
sessionId: this.sessionId || '',
518-
operationType: this.operationHandle.operationType?.toString(),
551+
operationType: mapOperationTypeToProto(this.operationHandle.operationType),
519552
});
520553
} catch (error: any) {
521554
this.context.getLogger().log(LogLevel.debug, `Error emitting statement.start event: ${error.message}`);

0 commit comments

Comments
 (0)