Skip to content

Commit 262fe59

Browse files
committed
Test for various arrow timestamp resolutions, and proper psp column types from arrow columns
1 parent 72cfdc6 commit 262fe59

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed
184 Bytes
Binary file not shown.

packages/perspective/test/js/constructors.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,20 @@ var meta_3 = {
4848
import arrow from "../arrow/test-null.arrow";
4949

5050
var arrow_result = [
51-
{"f32": 1.5, "f64": 1.5, "i64": 1, "i32": 1, "i16": 1, "i8": 1, "bool": true, "char": "a", "dict": "a", "datetime": +(new Date("2018-01-25"))},
52-
{"f32": 2.5, "f64": 2.5, "i64": 2, "i32": 2, "i16": 2, "i8": 2, "bool": false, "char": "b", "dict": "b", "datetime": +(new Date("2018-01-26"))},
53-
{"f32": 3.5, "f64": 3.5, "i64": 3, "i32": 3, "i16": 3, "i8": 3, "bool": true, "char": "c", "dict": "c", "datetime": +(new Date("2018-01-27"))},
54-
{"f32": 4.5, "f64": 4.5, "i64": 4, "i32": 4, "i16": 4, "i8": 4, "bool": false, "char": "d", "dict": "d", "datetime": +(new Date("2018-01-28"))},
55-
{"f32": null, "f64": null, "i64": null, "i32": null, "i16": null, "i8": null, "bool": null, "char": null, "dict": null, "datetime": null}
51+
{"f32": 1.5, "f64": 1.5, "i64": 1, "i32": 1, "i16": 1, "i8": 1, "bool": true, "char": "a", "dict": "a",
52+
"datetime(ms)": +(new Date("2018-01-25")), "datetime(us)": +(new Date("2018-01-25")), "datetime(ns)": +(new Date("2018-01-25"))},
53+
{"f32": 2.5, "f64": 2.5, "i64": 2, "i32": 2, "i16": 2, "i8": 2, "bool": false, "char": "b", "dict": "b",
54+
"datetime(ms)": +(new Date("2018-01-26")), "datetime(us)": +(new Date("2018-01-26")), "datetime(ns)": +(new Date("2018-01-26"))},
55+
{"f32": 3.5, "f64": 3.5, "i64": 3, "i32": 3, "i16": 3, "i8": 3, "bool": true, "char": "c", "dict": "c",
56+
"datetime(ms)": +(new Date("2018-01-27")), "datetime(us)": +(new Date("2018-01-27")), "datetime(ns)": +(new Date("2018-01-27"))},
57+
{"f32": 4.5, "f64": 4.5, "i64": 4, "i32": 4, "i16": 4, "i8": 4, "bool": false, "char": "d", "dict": "d",
58+
"datetime(ms)": +(new Date("2018-01-28")), "datetime(us)": +(new Date("2018-01-28")), "datetime(ns)": +(new Date("2018-01-28"))},
59+
{"f32": null, "f64": null, "i64": null, "i32": null, "i16": null, "i8": null, "bool": null, "char": null, "dict": null,
60+
"datetime(ms)": null, "datetime(us)": null, "datetime(ns)": null}
5661
];
5762

63+
var arrow_psp_internal_schema = [9, 10, 1, 2, 3, 4, 11, 19, 19, 12, 12, 12, 2];
64+
5865
var dt = new Date();
5966
var data_4 = [
6067
{'v': dt}
@@ -117,6 +124,29 @@ module.exports = (perspective) => {
117124
expect(arrow_result).toEqual(result);
118125
});
119126

127+
it("Arrow schema", async function () {
128+
// This only works for non parallel
129+
var table = perspective.table(arrow);
130+
let schema, stypes;
131+
let types = [];
132+
try{
133+
schema = table.gnode.get_tblschema();
134+
stypes = schema.types();
135+
136+
for (let i = 0; i < stypes.size(); i ++) {
137+
types.push(stypes.get(i).value);
138+
}
139+
expect(arrow_psp_internal_schema).toEqual(types);
140+
} finally {
141+
if (schema) {
142+
schema.delete();
143+
}
144+
if (stypes) {
145+
stypes.delete();
146+
}
147+
}
148+
});
149+
120150
it("CSV constructor", async function () {
121151
var table = perspective.table(csv);
122152
var view = table.view();

0 commit comments

Comments
 (0)