Skip to content

Commit

Permalink
fix: query Points without metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Sciator committed Aug 29, 2023
1 parent 464941f commit 862abcb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions packages/client/src/impl/QueryApiImpl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {RecordBatchReader} from 'apache-arrow'
import {RecordBatchReader, Type as ArrowType} from 'apache-arrow'
import QueryApi from '../QueryApi'
import {Ticket} from '../generated/flight/Flight'
import {FlightServiceClient} from '../generated/flight/Flight.client'
Expand Down Expand Up @@ -96,8 +96,30 @@ export default class QueryApiImpl implements QueryApi {
const columnSchema = batch.schema.fields[columnIndex]
const name = columnSchema.name
const value = batch.getChildAt(columnIndex)?.get(rowIndex)
const type = columnSchema.metadata.get('iox::column::type') as string
const [, , valueType, _fieldType] = type.split('::')
const arrowTypeId = columnSchema.typeId
const metaType = columnSchema.metadata.get('iox::column::type')

if (value === undefined || value === null) continue

if (
(name === 'measurement' || name == 'iox::measurement') &&
typeof value === 'string'
) {
point.measurement(value)
continue
}

if (!metaType) {
if (name === 'time' && arrowTypeId === ArrowType.Timestamp) {
point.timestamp(value)
} else {
point.field(name, value)
}

continue
}

const [, , valueType, _fieldType] = metaType.split('::')

if (valueType === 'field') {
if (_fieldType && value !== undefined && value !== null)
Expand Down

0 comments on commit 862abcb

Please sign in to comment.