Skip to content

Commit 4a0f504

Browse files
authored
Add test to read empty file (#512)
* Add test to read empty file * Add assert statements
1 parent 10dada0 commit 4a0f504

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

tests/data/empty.parquet

976 Bytes
Binary file not shown.

tests/data/generate_data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pandas as pd
12
import pyarrow as pa
23
import pyarrow.feather as feather
34
import pyarrow.parquet as pq
@@ -30,9 +31,14 @@ def write_data(table):
3031
)
3132

3233

34+
def write_empty_table():
35+
pd.DataFrame().to_parquet("empty.parquet")
36+
37+
3338
def main():
3439
table = create_data()
3540
write_data(table)
41+
write_empty_table()
3642

3743

3844
if __name__ == "__main__":

tests/js/read-write.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,15 @@ it("error produced trying to read file with arrayBuffer", (t) => {
7777
);
7878
}
7979
});
80+
81+
it("reads empty file", async (t) => {
82+
const dataPath = `${dataDir}/empty.parquet`;
83+
const buffer = readFileSync(dataPath);
84+
const arr = new Uint8Array(buffer);
85+
const table = tableFromIPC(wasm.readParquet(arr).intoIPCStream());
86+
87+
expect(table.schema.fields.length).toStrictEqual(0);
88+
expect(table.numRows).toStrictEqual(0);
89+
expect(table.numCols).toStrictEqual(0);
90+
// console.log("empty table schema", table.schema);
91+
});

0 commit comments

Comments
 (0)