Skip to content

Commit

Permalink
Upgrading napi, adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bidek56 committed Nov 26, 2023
1 parent aeb6d70 commit fbcbbee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ crate-type = ["cdylib", "lib"]
[dependencies]
ahash = "0.8.3"
bincode = "1.3.3"
napi = {version = "2.14.0", default-features = false, features = ["napi8", "serde-json", "experimental"]}
napi-derive = {version = "2.14.1", default-features = false}
napi = {version = "2.14.1", default-features = false, features = ["napi8", "serde-json"]}
napi-derive = {version = "2.14.2", default-features = false}
polars-core = {git = "https://github.com/pola-rs/polars.git", rev = "b13afbecac039205dacbaca766ecca4bf441b347", default-features = false}
polars-io = {git = "https://github.com/pola-rs/polars.git", rev = "b13afbecac039205dacbaca766ecca4bf441b347", default-features = false}
polars-lazy = {git = "https://github.com/pola-rs/polars.git", rev = "b13afbecac039205dacbaca766ecca4bf441b347", default-features = false}
thiserror = "1"
smartstring = { version = "1" }
smartstring = {version = "1"}
serde_json = {version = "1"}
either = "1.9"

Expand Down Expand Up @@ -52,7 +52,6 @@ features = [
"concat_str",
"row_hash",
"reinterpret",
"decompress-fast",
"mode",
"extract_jsonpath",
"lazy_regex",
Expand All @@ -66,8 +65,6 @@ features = [
"diff",
"pct_change",
"moment",
"true_div",
"dtype-categorical",
"diagonal_concat",
"horizontal_concat",
"abs",
Expand Down
24 changes: 17 additions & 7 deletions __tests__/lazyframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,30 @@ describe("lazyframe", () => {
const actual = await expected.lazy().collect();
expect(actual).toFrameEqual(expected);
});

test("describeOptimizedPlan", () => {
const df = pl
.DataFrame({
foo: [1, 2],
bar: ["a", "b"],
})
.lazy();
const actual = df.describeOptimizedPlan().replace(/\s+/g, " ");
expect(actual).toEqual(
`DF ["foo", "bar"]; PROJECT */2 COLUMNS; SELECTION: "None"`,
);
let actual = df.describeOptimizedPlan().replace(/\s+/g, " ");
const expected = `DF ["foo", "bar"]; PROJECT */2 COLUMNS; SELECTION: "None"`
expect(actual).toEqual(expected);
actual = df.describePlan().replace(/\s+/g, " ");
expect(actual).toEqual(expected);
});
test("cache", () => {
const df = pl.DataFrame({
foo: [1, 2, 3],
});
const expected = pl.DataFrame({
foo: [1, 2, 3],
});
let actual = df.lazy().cache().collectSync();
expect(actual).toFrameEqual(expected);
actual = df.lazy().clone().collectSync();
expect(actual).toFrameEqual(expected);
});
test("drop", () => {
const df = pl.DataFrame({
Expand Down Expand Up @@ -240,12 +252,10 @@ describe("lazyframe", () => {
.lazy()
.explode("list_1")
.collectSync();

const expected = pl.DataFrame({
letters: ["c", "c", "a", "a"],
list_1: [1, 2, 1, 3],
});

expect(actual).toFrameEqualIgnoringOrder(expected);
});
test("fetch", async () => {
Expand Down

0 comments on commit fbcbbee

Please sign in to comment.