mirror of
https://github.com/asadbek064/hyparquet.git
synced 2025-12-30 00:46:38 +00:00
Tests, assemble
This commit is contained in:
parent
797db7b4df
commit
5412ff9bb7
2
demo.js
2
demo.js
@ -230,6 +230,6 @@ function renderTable(header, data) {
|
||||
function stringify(value) {
|
||||
if (value === undefined) return ''
|
||||
if (typeof value === 'string') return value
|
||||
if (typeof value === 'object') return JSON.stringify(value)
|
||||
if (typeof value === 'object') return JSON.stringify(toJson(value))
|
||||
return value
|
||||
}
|
||||
|
||||
@ -27,12 +27,12 @@
|
||||
"typecheck": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "20.12.10",
|
||||
"@types/node": "20.12.11",
|
||||
"@typescript-eslint/eslint-plugin": "7.8.0",
|
||||
"@vitest/coverage-v8": "1.6.0",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-plugin-import": "2.29.1",
|
||||
"eslint-plugin-jsdoc": "48.2.3",
|
||||
"eslint-plugin-jsdoc": "48.2.4",
|
||||
"http-server": "14.1.1",
|
||||
"hysnappy": "0.3.1",
|
||||
"typescript": "5.4.5",
|
||||
|
||||
@ -122,4 +122,37 @@ describe('assembleObjects', () => {
|
||||
[undefined, [5, 6]],
|
||||
])
|
||||
})
|
||||
|
||||
it('should handle nonnullable int_map_array keys', () => {
|
||||
const definitionLevels = [3, 4, 3, 3]
|
||||
const repetitionLevels = [0, 1, 1, 1]
|
||||
const values = ['k1']
|
||||
const result = assembleObjects(definitionLevels, repetitionLevels, values, true, 4, 2)
|
||||
expect(result).toEqual([[[], ['k1'], [], []]])
|
||||
})
|
||||
|
||||
it('should handle nonnullable int_map_array values', () => {
|
||||
const definitionLevels = [3, 5, 3, 3]
|
||||
const repetitionLevels = [0, 1, 1, 1]
|
||||
const values = ['v1']
|
||||
const result = assembleObjects(definitionLevels, repetitionLevels, values, true, 5, 2)
|
||||
expect(result).toEqual([[[], ['v1'], [], []]])
|
||||
})
|
||||
|
||||
it('should handle mixed optional and required', () => {
|
||||
// from datapage_v2.snappy.parquet e
|
||||
const definitionLevels = [2, 2, 2, 0, 0, 2, 2, 2, 2, 2]
|
||||
const repetitionLevels = [0, 1, 1, 0, 0, 0, 1, 1, 0, 1]
|
||||
const values = [1, 2, 3, 1, 2, 3, 1, 2]
|
||||
const result = assembleObjects(definitionLevels, repetitionLevels, values, true, 2, 1)
|
||||
expect(result).toEqual([[1, 2, 3], undefined, undefined, [1, 2, 3], [1, 2]])
|
||||
})
|
||||
|
||||
it('should handle nested required', () => {
|
||||
// from nonnullable.impala.parquet nested_Struct i
|
||||
const definitionLevels = [0]
|
||||
const repetitionLevels = [0]
|
||||
const result = assembleObjects(definitionLevels, repetitionLevels, [], false, 2, 2)
|
||||
expect(result).toEqual([[[]]])
|
||||
})
|
||||
})
|
||||
|
||||
@ -23,10 +23,7 @@ describe('parquetRead', () => {
|
||||
file,
|
||||
rowEnd: 2,
|
||||
onComplete: rows => {
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
expect(toJson(rows)).toEqual([
|
||||
[1], [2],
|
||||
])
|
||||
expect(toJson(rows)).toEqual([[1], [2]])
|
||||
},
|
||||
})
|
||||
})
|
||||
@ -45,7 +42,6 @@ describe('parquetRead', () => {
|
||||
})
|
||||
},
|
||||
onComplete: (rows) => {
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
expect(toJson(rows)).toEqual([
|
||||
[2],
|
||||
[3],
|
||||
@ -71,7 +67,6 @@ describe('parquetRead', () => {
|
||||
})
|
||||
},
|
||||
onComplete: rows => {
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
expect(toJson(rows)).toEqual([
|
||||
[[1, 2, 3]],
|
||||
[null],
|
||||
@ -105,7 +100,6 @@ describe('parquetRead', () => {
|
||||
})
|
||||
},
|
||||
onComplete: rows => {
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
expect(toJson(rows)).toEqual([
|
||||
[{ k1: 1, k2: 100 }],
|
||||
[{ k1: 2, k2: null }],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user