@@ -36,6 +36,7 @@ import { OperationChunksIterator, OperationRowsIterator } from './utils/Operatio
3636import HiveDriverError from './errors/HiveDriverError' ;
3737import IClientContext from './contracts/IClientContext' ;
3838import ExceptionClassifier from './telemetry/ExceptionClassifier' ;
39+ import { mapOperationTypeToTelemetryType , mapResultFormatToTelemetryType } from './telemetry/telemetryTypeMappers' ;
3940
4041interface DBSQLOperationConstructorOptions {
4142 handle : TOperationHandle ;
@@ -52,59 +53,6 @@ async function delay(ms?: number): Promise<void> {
5253 } ) ;
5354}
5455
55- /**
56- * Map Thrift TOperationType to proto Operation.Type enum string.
57- */
58- function mapOperationTypeToProto ( operationType ?: TOperationType ) : string | undefined {
59- if ( operationType === undefined ) {
60- return undefined ;
61- }
62-
63- switch ( operationType ) {
64- case TOperationType . EXECUTE_STATEMENT :
65- return 'EXECUTE_STATEMENT' ;
66- case TOperationType . GET_TYPE_INFO :
67- return 'LIST_TYPE_INFO' ;
68- case TOperationType . GET_CATALOGS :
69- return 'LIST_CATALOGS' ;
70- case TOperationType . GET_SCHEMAS :
71- return 'LIST_SCHEMAS' ;
72- case TOperationType . GET_TABLES :
73- return 'LIST_TABLES' ;
74- case TOperationType . GET_TABLE_TYPES :
75- return 'LIST_TABLE_TYPES' ;
76- case TOperationType . GET_COLUMNS :
77- return 'LIST_COLUMNS' ;
78- case TOperationType . GET_FUNCTIONS :
79- return 'LIST_FUNCTIONS' ;
80- case TOperationType . UNKNOWN :
81- default :
82- return 'TYPE_UNSPECIFIED' ;
83- }
84- }
85-
86- /**
87- * Map Thrift TSparkRowSetType to proto ExecutionResult.Format enum string.
88- */
89- function mapResultFormatToProto ( resultFormat ?: TSparkRowSetType ) : string | undefined {
90- if ( resultFormat === undefined ) {
91- return undefined ;
92- }
93-
94- switch ( resultFormat ) {
95- case TSparkRowSetType . ARROW_BASED_SET :
96- return 'INLINE_ARROW' ;
97- case TSparkRowSetType . COLUMN_BASED_SET :
98- return 'COLUMNAR_INLINE' ;
99- case TSparkRowSetType . ROW_BASED_SET :
100- return 'INLINE_JSON' ;
101- case TSparkRowSetType . URL_BASED_SET :
102- return 'EXTERNAL_LINKS' ;
103- default :
104- return 'FORMAT_UNSPECIFIED' ;
105- }
106- }
107-
10856export default class DBSQLOperation implements IOperation {
10957 private readonly context : IClientContext ;
11058
@@ -569,7 +517,7 @@ export default class DBSQLOperation implements IOperation {
569517 telemetryEmitter . emitStatementStart ( {
570518 statementId : this . id ,
571519 sessionId : this . sessionId || '' ,
572- operationType : mapOperationTypeToProto ( this . operationHandle . operationType ) ,
520+ operationType : mapOperationTypeToTelemetryType ( this . operationHandle . operationType ) ,
573521 } ) ;
574522 } catch ( error : any ) {
575523 this . context . getLogger ( ) . log ( LogLevel . debug , `Error emitting statement.start event: ${ error . message } ` ) ;
@@ -594,7 +542,7 @@ export default class DBSQLOperation implements IOperation {
594542 if ( ! this . metadata && ! this . cancelled ) {
595543 await this . getMetadata ( ) ;
596544 }
597- resultFormat = mapResultFormatToProto ( this . metadata ?. resultFormat ) ;
545+ resultFormat = mapResultFormatToTelemetryType ( this . metadata ?. resultFormat ) ;
598546 } catch ( error ) {
599547 // If metadata fetch fails, continue without it
600548 resultFormat = undefined ;
0 commit comments