hyparquet/test/read.test.js

59 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-01-15 19:08:48 +00:00
import { describe, expect, it } from 'vitest'
import { parquetRead } from '../src/hyparquet.js'
import { toJson } from '../src/toJson.js'
2024-01-20 20:17:11 +00:00
import { fileToAsyncBuffer } from './helpers.js'
2024-01-15 19:08:48 +00:00
describe('parquetMetadataAsync', () => {
it('should parse data from addrtype-missing-value.parquet', async () => {
const asyncBuffer = fileToAsyncBuffer('test/files/addrtype-missing-value.parquet')
await parquetRead({
file: asyncBuffer,
onComplete: (rows) => {
2024-01-20 20:17:11 +00:00
expect(rows).toEqual(addrtypeData)
2024-01-15 19:08:48 +00:00
},
})
})
it('should parse data from rowgroups.parquet', async () => {
const asyncBuffer = fileToAsyncBuffer('test/files/rowgroups.parquet')
await parquetRead({
file: asyncBuffer,
onComplete: (rows) => {
expect(toJson(rows)).toEqual(rowgroupsData)
},
})
})
})
// Parquet v1 from DuckDB
const addrtypeData = [
['Block'],
['Intersection'],
['Block'],
['Block'],
[undefined],
['Block'],
['Intersection'],
['Block'],
['Block'],
['Intersection'],
]
const rowgroupsData = [
[1],
[2],
[3],
[4],
[5],
[6],
[7],
[8],
[9],
[10],
[11],
[12],
[13],
[14],
[15],
]