Skip to content

Commit

Permalink
Add writeGeoParquet to JS binding & overture parquet test (#622)
Browse files Browse the repository at this point in the history
kylebarron authored Apr 23, 2024
1 parent 42aa07b commit a032e3b
Showing 5 changed files with 389 additions and 5 deletions.
78 changes: 78 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -24,7 +24,13 @@ geos = ["dep:geos"]
geozero = ["dep:geozero"]
ipc_compression = ["arrow-ipc/lz4", "arrow-ipc/zstd"]
parquet = ["dep:parquet"]
parquet_async = ["parquet", "parquet/async", "dep:futures", "dep:tokio"]
parquet_async = [
"parquet",
"parquet/async",
"dep:futures",
"dep:tokio",
"dep:object_store",
]
parquet_compression = [
"parquet/snap",
"parquet/brotli",
@@ -96,9 +102,15 @@ bytes = "1.5.0"
criterion = { version = "0.5", features = ["html_reports"] }
gdal = { version = "0.16", features = ["bindgen"] }
geozero = { version = "0.12", features = ["with-wkb"] }
parquet = "51"
sqlx = { version = "0.7", default-features = false, features = ["postgres"] }
tokio = { version = "1.9", features = ["macros", "fs", "rt-multi-thread"] }
url = "*"
object_store = { version = "*", features = ["http", "aws"] }
parquet = { version = "51", default-features = false, features = [
"arrow",
"object_store",
] }


[lib]
doctest = true
1 change: 1 addition & 0 deletions js/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion js/src/io/parquet/sync.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use arrow_wasm::Table;
// use parquet_wasm::utils::assert_parquet_file_not_empty;
use bytes::Bytes;
use geoarrow::io::parquet::{read_geoparquet as _read_geoparquet, ParquetReaderOptions};
use geoarrow::io::parquet::{
read_geoparquet as _read_geoparquet, write_geoparquet as _write_geoparquet,
ParquetReaderOptions,
};
use wasm_bindgen::prelude::*;

use crate::error::WasmResult;
@@ -34,3 +37,15 @@ pub fn read_geoparquet(file: Vec<u8>) -> WasmResult<Table> {
let (schema, batches) = geo_table.into_inner();
Ok(Table::new(schema, batches))
}

/// Write table to GeoParquet
///
/// Note that this consumes the table input
#[wasm_bindgen(js_name = writeGeoParquet)]
pub fn write_geoparquet(table: Table) -> WasmResult<Vec<u8>> {
let (schema, batches) = table.into_inner();
let mut rust_table = geoarrow::table::Table::try_new(schema, batches)?;
let mut output_file: Vec<u8> = vec![];
_write_geoparquet(&mut rust_table, &mut output_file, &Default::default())?;
Ok(output_file)
}
282 changes: 280 additions & 2 deletions src/io/parquet/reader/async.rs

Large diffs are not rendered by default.

0 comments on commit a032e3b

Please sign in to comment.