feat(rust/sedona-raster-gdal): add RS_MetaData#833
Conversation
e6ea9a9 to
201f7f7
Compare
Commit changes made to Cargo.lock
77c404f to
3168431
Compare
paleolimbot
left a comment
There was a problem hiding this comment.
Thank you!
It would be great to get the example to be user runnable (whatever we do here will also help make realistic examples for other functions, too). Other than that these are just nits.
| ```sql | ||
| SELECT RS_MetaData( | ||
| RS_FromPath('../../../submodules/sedona-testing/data/raster/test4.tiff') | ||
| ); | ||
| ``` |
There was a problem hiding this comment.
Can we use the http:// url here so that this example is runnable by a user? Or enable RS_Example("fixture name")?
| Field::new("upperLeftX", DataType::Float64, true), | ||
| Field::new("upperLeftY", DataType::Float64, true), | ||
| Field::new("gridWidth", DataType::Int64, true), |
There was a problem hiding this comment.
I get that we probably have to do this for compatibility with Sedona Spark, but it's a bit of a bummer these aren't snake_case.
| let mut num_bands_builder = UInt32Builder::with_capacity(capacity); | ||
| let mut tile_width_builder = UInt64Builder::with_capacity(capacity); | ||
| let mut tile_height_builder = UInt64Builder::with_capacity(capacity); | ||
| let mut struct_validity = Vec::with_capacity(capacity); |
There was a problem hiding this comment.
Can you use a NullsBuffer here?
| let srid = match raster.crs() { | ||
| None => 0i32, | ||
| Some(crs_str) => match deserialize_crs(crs_str) { | ||
| Ok(Some(crs_ref)) => crs_ref | ||
| .srid() | ||
| .ok() | ||
| .flatten() | ||
| .and_then(|s| i32::try_from(s).ok()) | ||
| .unwrap_or(0), | ||
| _ => 0i32, | ||
| }, | ||
| }; | ||
| srid_builder.append_value(srid); |
There was a problem hiding this comment.
I get how this is needed for compatibility, but we should arguably change the SedonaSpark version to return a string here so that we avoid this being lossy for un-sridable tiffs.
| fn invoke_array_result(raster_array: StructArray) -> StructArray { | ||
| metadata_udf_tester() | ||
| .invoke_array(Arc::new(raster_array)) | ||
| .unwrap() | ||
| .as_struct() | ||
| .clone() | ||
| } | ||
|
|
||
| fn assert_scalar_result(result: ScalarValue) -> Arc<StructArray> { | ||
| match result { | ||
| ScalarValue::Struct(struct_array) => struct_array, | ||
| other => panic!("Expected struct scalar result, got {other:?}"), | ||
| } | ||
| } |
There was a problem hiding this comment.
For analyze agg we have a JSON based struct approach that could be copied or moved to sedona-testing and reused (but your tests here are quite readable and I'm not sure it's an improvement other than less helper code).
sedona-db/rust/sedona-functions/src/st_analyze_agg.rs
Lines 519 to 540 in f64ed45
Summary
RS_MetaDatabacked by the GDAL dataset providerDependency
RS_FromPath)RS_FromPathcommit because GitHub upstream PRs cannot target a fork-only base branch.Testing
cargo test -p sedona-raster-gdalcargo clippy -p sedona-raster-gdal -- -D warningscargo test -p sedona-gdal