Skip to content

Commit 316d1e9

Browse files
samikshya-dbclaude
andcommitted
Ensure statement_type always populated in telemetry
Fix issue where statement_type was null in telemetry payloads. Changes: - mapOperationTypeToTelemetryType() now always returns a string, defaulting to 'TYPE_UNSPECIFIED' when operationType is undefined - statement_type always included in sql_operation telemetry log This ensures that even if the Thrift operationHandle doesn't have operationType set, the telemetry will include 'TYPE_UNSPECIFIED' instead of null. Root cause: operationHandle.operationType from Thrift response can be undefined, resulting in null statement_type in telemetry logs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 8ff09a9 commit 316d1e9

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/telemetry/DatabricksTelemetryExporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export default class DatabricksTelemetryExporter {
329329
// Only create sql_operation if we have any fields to include
330330
if (metric.operationType || metric.compressed !== undefined || metric.resultFormat || metric.chunkCount) {
331331
log.entry.sql_driver_log.sql_operation = {
332-
...(metric.operationType && { statement_type: metric.operationType }),
332+
statement_type: metric.operationType,
333333
...(metric.compressed !== undefined && { is_compressed: metric.compressed }),
334334
...(metric.resultFormat && { execution_result: metric.resultFormat }),
335335
};

lib/telemetry/telemetryTypeMappers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import { TOperationType, TSparkRowSetType } from '../../thrift/TCLIService_types
1818

1919
/**
2020
* Map Thrift TOperationType to telemetry Operation.Type enum string.
21+
* Returns 'TYPE_UNSPECIFIED' if operationType is undefined or unknown.
2122
*/
22-
export function mapOperationTypeToTelemetryType(operationType?: TOperationType): string | undefined {
23+
export function mapOperationTypeToTelemetryType(operationType?: TOperationType): string {
2324
if (operationType === undefined) {
24-
return undefined;
25+
return 'TYPE_UNSPECIFIED';
2526
}
2627

2728
switch (operationType) {

0 commit comments

Comments
 (0)