@@ -103,11 +103,13 @@ function buildColumnIndexMap(columns: GreptimeDBColumnSchema[] | undefined): Col
103103
104104/** GreptimeDB /v1/sql includes data_type on every column_schemas entry. */
105105function getColumnDataType ( columns : GreptimeDBColumnSchema [ ] , index : number ) : string {
106- const dataType = columns [ index ] . data_type ;
106+ const column = columns [ index ] ;
107+ if ( ! column ) {
108+ throw new Error ( `GreptimeDB SQL response missing column at index ${ index } ` ) ;
109+ }
110+ const dataType = column . data_type ;
107111 if ( ! dataType ) {
108- throw new Error (
109- `GreptimeDB SQL response missing data_type for column "${ columns [ index ] ?. name ?? String ( index ) } "`
110- ) ;
112+ throw new Error ( `GreptimeDB SQL response missing data_type for column "${ column . name } "` ) ;
111113 }
112114 return dataType ;
113115}
@@ -271,9 +273,7 @@ function buildSearchResult(records: GreptimeDBRecords | undefined): TraceSearchR
271273
272274function isIntegerGreptimeDataType ( dataType : string ) : boolean {
273275 const normalized = dataType . toLowerCase ( ) ;
274- return (
275- normalized . includes ( 'int' ) || normalized . includes ( 'uint' ) || normalized === 'bigint'
276- ) ;
276+ return normalized . includes ( 'int' ) || normalized . includes ( 'uint' ) || normalized === 'bigint' ;
277277}
278278
279279/**
@@ -381,9 +381,7 @@ function convertRowsToTrace(records: GreptimeDBRecords | undefined): otlptracev1
381381 const durationIndex = map . duration_nano ?? map . duration_ns ;
382382
383383 const startTimeUnixNano =
384- ( startIndex !== undefined
385- ? ( toNanoString ( row [ startIndex ] , getColumnDataType ( columns , startIndex ) ) ?? '0' )
386- : '0' ) ;
384+ startIndex !== undefined ? ( toNanoString ( row [ startIndex ] , getColumnDataType ( columns , startIndex ) ) ?? '0' ) : '0' ;
387385 const endTimeUnixNano =
388386 ( endIndex !== undefined
389387 ? ( toNanoString ( row [ endIndex ] , getColumnDataType ( columns , endIndex ) ) ?? '0' )
@@ -408,8 +406,7 @@ function convertRowsToTrace(records: GreptimeDBRecords | undefined): otlptracev1
408406 // span_events / span_links: JSON columns (data_type Json). Only events need OTLP time parsing.
409407 const spanEvents = parseJsonArray ( getCell ( row , map , [ 'span_events' ] ) ) . map ( ( event ) => {
410408 const e = event as Record < string , unknown > ;
411- const eventTime =
412- otlpEventTimeToNanoString ( e . timeUnixNano ?? e . time_unix_nano ) ?? startTimeUnixNano ;
409+ const eventTime = otlpEventTimeToNanoString ( e . timeUnixNano ?? e . time_unix_nano ) ?? startTimeUnixNano ;
413410 const eventName = getString ( e . name ) ?? 'event' ;
414411 const attrs = e . attributes as Record < string , unknown > | undefined ;
415412 const attributes = attrs
0 commit comments