Skip to content

Commit

Permalink
fix: add stub functions for wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Dec 30, 2024
1 parent 14b234c commit 4c21259
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/rust/src/expr/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ impl PlRExpr {
.into())
}

// TODO: Work around for <https://github.com/yutannihilation/savvy/issues/333>
#[cfg(target_arch = "wasm32")]
#[allow(unused_variables)]
fn str_json_path_match(&self, pat: &PlRExpr) -> Result<Self> {
Err(RPolarsErr::Other(format!("`Not supported in WASM")).into())
}

// fn str_json_decode(&self, dtype: &PlRExpr, infer_schema_len: &PlRExpr) -> Result<Self> {
// let dtype = robj_to!(Option, RPolarsDataType, dtype)?.map(|dty| dty.0);
// let infer_schema_len = robj_to!(Option, usize, infer_schema_len)?;
Expand Down
7 changes: 7 additions & 0 deletions src/rust/src/expr/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ impl PlRExpr {
Ok(self.inner.clone().struct_().json_encode().into())
}

// TODO: Work around for <https://github.com/yutannihilation/savvy/issues/333>
#[cfg(target_arch = "wasm32")]
#[allow(unused_variables)]
fn struct_json_encode(&self) -> Result<Self> {
Err(RPolarsErr::Other(format!("`Not supported in WASM")).into())
}

fn struct_with_fields(&self, fields: ListSexp) -> Result<Self> {
let fields = <Wrap<Vec<Expr>>>::from(fields).0;
let e = self
Expand Down
49 changes: 49 additions & 0 deletions src/rust/src/lazyframe/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,32 @@ impl PlRLazyFrame {
Ok(r.finish().map_err(RPolarsErr::from)?.into())
}

// TODO: Work around for <https://github.com/yutannihilation/savvy/issues/333>
#[cfg(target_arch = "wasm32")]
#[allow(unused_variables)]
fn new_from_parquet(
source: StringSexp,
cache: bool,
parallel: &str,
rechunk: bool,
low_memory: bool,
use_statistics: bool,
try_parse_hive_dates: bool,
retries: NumericScalar,
glob: bool,
allow_missing_columns: bool,
row_index_offset: NumericScalar,
storage_options: Option<StringSexp>,
n_rows: Option<NumericScalar>,
row_index_name: Option<&str>,
hive_partitioning: Option<bool>,
schema: Option<ListSexp>,
hive_schema: Option<ListSexp>,
include_file_paths: Option<&str>,
) -> Result<Self> {
Err(RPolarsErr::Other(format!("`Not supported in WASM")).into())
}

// TODO: Refactor with adding `parquet` feature as like Python Polars
#[cfg(not(target_arch = "wasm32"))]
fn new_from_parquet(
Expand Down Expand Up @@ -567,6 +593,29 @@ impl PlRLazyFrame {
Ok(lf.into())
}

// TODO: Work around for <https://github.com/yutannihilation/savvy/issues/333>
#[cfg(target_arch = "wasm32")]
#[allow(unused_variables)]
fn new_from_ndjson(
source: StringSexp,
low_memory: bool,
rechunk: bool,
ignore_errors: bool,
retries: NumericScalar,
row_index_offset: NumericScalar,
row_index_name: Option<&str>,
infer_schema_length: Option<NumericScalar>,
schema: Option<ListSexp>,
schema_overrides: Option<ListSexp>,
batch_size: Option<NumericScalar>,
n_rows: Option<NumericScalar>,
include_file_paths: Option<&str>,
storage_options: Option<StringSexp>,
file_cache_ttl: Option<NumericScalar>,
) -> Result<Self> {
Err(RPolarsErr::Other(format!("`Not supported in WASM")).into())
}

// TODO: Refactor with adding `json` feature as like Python Polars
#[cfg(not(target_arch = "wasm32"))]
fn new_from_ndjson(
Expand Down

0 comments on commit 4c21259

Please sign in to comment.