Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions python/sedonadb/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ def test_read_parquet(con, geoarrow_data):
assert len(tab) == 244


def test_read_parquet_local_glob(con, geoarrow_data):
# The above test uses .glob() method, this test uses the raw string
tab = con.read_parquet(
geoarrow_data / "example/files/*_geo.parquet"
).to_arrow_table()
assert tab["geometry"].type.extension_name == "geoarrow.wkb"
assert len(tab) == 244

tab = con.read_parquet(
geoarrow_data / "example/files/example_polygon-*geo.parquet"
).to_arrow_table()
assert len(tab) == 12


def test_read_parquet_error(con):
with pytest.raises(sedonadb._lib.SedonaError, match="No table paths were provided"):
con.read_parquet([])
Expand Down
24 changes: 14 additions & 10 deletions rust/sedona-geoparquet/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use datafusion::{
file_format::parquet::ParquetFormat,
listing::{ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl},
},
execution::{context::DataFilePaths, options::ReadOptions, SessionState},
execution::{options::ReadOptions, SessionState},
prelude::{ParquetReadOptions, SessionConfig, SessionContext},
};
use datafusion_common::{exec_err, Result};
Expand All @@ -36,12 +36,11 @@ use crate::format::GeoParquetFormat;
/// Because [ListingTable] implements `TableProvider`, this can be used to
/// implement geo-aware Parquet reading with interfaces that are otherwise
/// hard-coded to the built-in Parquet reader.
pub async fn geoparquet_listing_table<P: DataFilePaths>(
pub async fn geoparquet_listing_table(
context: &SessionContext,
table_paths: P,
table_paths: Vec<ListingTableUrl>,
options: GeoParquetReadOptions<'_>,
) -> Result<ListingTable> {
let table_paths = table_paths.to_urls()?;
let session_config = context.copied_config();
let listing_options =
options.to_listing_options(&session_config, context.copied_table_options());
Expand Down Expand Up @@ -134,7 +133,9 @@ mod test {
let data_dir = geoarrow_data_dir().unwrap();
let tab = geoparquet_listing_table(
&ctx,
format!("{data_dir}/example/files/*_geo.parquet"),
vec![
ListingTableUrl::parse(format!("{data_dir}/example/files/*_geo.parquet")).unwrap(),
],
GeoParquetReadOptions::default(),
)
.await
Expand Down Expand Up @@ -169,15 +170,18 @@ mod test {
#[tokio::test]
async fn listing_table_errors() {
let ctx = SessionContext::new();
let err =
geoparquet_listing_table(&ctx, Vec::<String>::new(), GeoParquetReadOptions::default())
.await
.unwrap_err();
let err = geoparquet_listing_table(
&ctx,
Vec::<ListingTableUrl>::new(),
GeoParquetReadOptions::default(),
)
.await
.unwrap_err();
assert_eq!(err.message(), "No table paths were provided");

let err = geoparquet_listing_table(
&ctx,
"foofy.wrongextension",
vec![ListingTableUrl::parse("foofy.wrongextension").unwrap()],
GeoParquetReadOptions::default(),
)
.await
Expand Down