Skip to content

Commit

Permalink
Adding null to string dtype conversion (#263)
Browse files Browse the repository at this point in the history
Adding null to string dtype conversion to close #262
  • Loading branch information
Bidek56 authored Sep 4, 2024
1 parent 08d181f commit 1828912
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions __tests__/io.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ describe("read:json", () => {
json.slice(0, 30),
);
});
it("can read null json from buffer", () => {
const json = [
JSON.stringify({ bar: 1, foo: "a", nul: null }),
JSON.stringify({ bar: 2, foo: "b", nul: null }),
"",
].join("\n");
const df = pl.readJSON(Buffer.from(json), { format: "lines" });
const actualCols = df.getColumns().map((x) => x.dtype);
expect(actualCols).toEqual([pl.Int64, pl.Utf8, pl.Null]);
});
});

describe("scan", () => {
Expand Down
1 change: 1 addition & 0 deletions src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ impl ToNapiValue for Wrap<DataType> {
obj.set("inner", inner_arr)?;
Object::to_napi_value(env, obj)
}
DataType::Null => String::to_napi_value(env, "Null".to_owned()),
DataType::Time => String::to_napi_value(env, "Time".to_owned()),
DataType::Object(..) => String::to_napi_value(env, "Object".to_owned()),
DataType::Categorical(..) => String::to_napi_value(env, "Categorical".to_owned()),
Expand Down

0 comments on commit 1828912

Please sign in to comment.