Skip to content

Commit

Permalink
refactor: simplify iterating over Arrow's batches (#437)
Browse files Browse the repository at this point in the history
* refactor: simplify iterating over Arrow's batches

* docs: update CHANGELOG.md
  • Loading branch information
bednar authored Oct 14, 2024
1 parent 4d369bd commit d2b1d0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 0.12.0 [unreleased]

### Bugfix

1. [437](https://github.com/InfluxCommunity/influxdb3-js/pull/437): Simplify iterating over Arrow's batches in `QueryAPI`

## 0.11.0 [2024-09-13]

### Features
Expand Down
11 changes: 4 additions & 7 deletions packages/client/src/impl/QueryApiImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,11 @@ export default class QueryApiImpl implements QueryApi {
const batches = this._queryRawBatches(query, database, options)

for await (const batch of batches) {
for (let rowIndex = 0; rowIndex < batch.numRows; rowIndex++) {
const row: Record<string, any> = {}
for (let columnIndex = 0; columnIndex < batch.numCols; columnIndex++) {
const name = batch.schema.fields[columnIndex].name
const value = batch.getChildAt(columnIndex)?.get(rowIndex)
row[name] = value
const row: Record<string, any> = {}
for (const batchRow of batch) {
for (const column of batch.schema.fields) {
row[column.name] = batchRow[column.name]
}

yield row
}
}
Expand Down

0 comments on commit d2b1d0f

Please sign in to comment.