Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug while running polars #17346

Closed
cojmeister opened this issue Jan 11, 2023 · 4 comments · Fixed by #17369
Closed

bug while running polars #17346

cojmeister opened this issue Jan 11, 2023 · 4 comments · Fixed by #17369
Assignees
Labels
needs investigation requires further investigation before determining if it is an issue or not node compat node native extension related to the node-api (.node)

Comments

@cojmeister
Copy link

Recieved this message while running my code:

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.29.2
Args: ["deno", "run", "--unstable", "--allow-read", "--allow-ffi", "FirstProg.ts"]

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BadType { actual: "v8::data::Value", expected: "v8::data::External" }', cli/napi/js_native_api.rs:2256:54
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is the code I'm running:

import pl from "npm:nodejs-polars";

function run() {
  const file = "./foods.csv";
  const df = pl.readCSV(file)
    .withColumns(
      pl.col("*"),
      pl.col("category").str.toUpperCase().cast(pl.Categorical),
      pl.col("calories").multiplyBy(2).cast(pl.Int32),
      pl.col("fats_g").str,
    )
    //   .filter(pl.col("calories").gt(100).over(pl.col("category")))

    .sort(pl.col("sugars_g"));
  console.log(df.toString());
}

run();
@bartlomieju bartlomieju added needs investigation requires further investigation before determining if it is an issue or not node compat node native extension related to the node-api (.node) labels Jan 11, 2023
@bartlomieju
Copy link
Member

Can you provide contents of foods.csv file?

@cojmeister
Copy link
Author

category,calories,fats_g,sugars_g,time
meat,101,8,0,08:40:06.12345
vegetables,44,0.3,3,08:40:06.12345
seafood,129,4,1,08:40:06.12345
fruit,49,4.4,0,08:40:06.12345
meat,95,4,0,08:40:06.12345
vegetables,24,0,1,08:40:06.12345
fruit,123,0,24,08:40:06.12345
fruit,59,0,9,08:40:06.12345
fruit,27,0,2,08:40:06.12345
vegetables,21,0,3,08:40:06.12345
fruit,61,0,12,08:40:06.12345
vegetables,26,0,4,08:40:06.12345
seafood,146,6,2,08:40:06.12345
vegetables,23,0,2,08:40:06.12345
fruit,51,1,13,08:40:06.12345
meat,111,8,2,08:40:06.12345
seafood,104,4,1,08:40:06.12345
meat,123,12,0,08:40:06.12345
seafood,201,8,4,08:40:06.12345
vegetables,35,1,7,08:40:06.12345
vegetables,21,1,3,08:40:06.12345
seafood,133,1.6,1,08:40:06.12345
meat,110,5,0,08:40:06.12345
seafood,192,6,0,08:40:06.12345
seafood,142,4,0,08:40:06.12345
fruit,31,0,4,08:40:06.12345
seafood,194,12,1,08:40:06.12345

@bartlomieju bartlomieju self-assigned this Jan 11, 2023
@kamilogorek
Copy link
Contributor

import pl from "npm:nodejs-polars";
pl.readCSV("foo\nbar").withColumns(pl.col("foo").str);

This is the minimal repro-case, and the cause is accessing the column (which is Expr type in polars) .str property.
Just a quick check, had no time to debug this further yet.

@bartlomieju
Copy link
Member

I already have a fix done, I will open a PR later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation requires further investigation before determining if it is an issue or not node compat node native extension related to the node-api (.node)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants