I have an Arrow Table with a column full of timestamps. Ultimately, I'm calling .toArray() on the Table to pass it through to some legacy code. This legacy code is expecting JS Date objects instead of timestamps. What's the most efficient way to do this conversion?
I solved this problem like this:
import { Column, DataType, DateVector, Table } from "apache-arrow"
const columns = new Array(table.numCols)
for (let i = 0; i < table.numCols; i++) {
const column = table.getColumnAt(i)
if (DataType.isTimestamp(column.type)) {
columns[i] = Column.new(column.name, DateVector.from(Array.from(column, (d) => new Date(d))))
} else {
columns[i] = column
}
}
const newTable = Table.new.apply(null, columns)