-
Notifications
You must be signed in to change notification settings - Fork 53
feat(rust/sedona-raster-gdal): add RS_FromPath #831
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
Open
Kontinuation
wants to merge
8
commits into
apache:main
Choose a base branch
from
Kontinuation:pr-c-rs-frompath
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
908093c
feat(rust/sedona-raster-gdal): add RS_FromPath
c7decc3
fix(rust/sedona-raster-gdal): align RS_FromPath with the single-path API
73927fa
Refactored RS_FromPath after manual reviewing
cfe08e1
fix(rust/sedona-raster-gdal): cover RS_FromPath edge cases
7af8c93
fix(docs/reference/sql): use checked-in raster for RS_FromPath
ebb7f15
fix(rust/sedona-raster-gdal): address review follow-ups
2b03dd8
Fix compilation and tests after rebasing
57edaa8
fix(rust/sedona-raster-gdal): use executor shape handling in RS_FromPath
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| title: RS_FromPath | ||
| description: Creates an out-of-database raster from a raster file path. | ||
| kernels: | ||
| - returns: raster | ||
| args: | ||
| - name: path | ||
| type: string | ||
| --- | ||
|
|
||
| ## Description | ||
|
|
||
| Loads raster metadata from the file at `path` and returns a raster whose bands | ||
| reference the source file as out-db bands. | ||
|
|
||
| This is useful when you want to work with rasters stored on disk without copying | ||
| their pixel data into the raster value itself. | ||
|
|
||
| ## Examples | ||
|
|
||
| ```sql | ||
| SELECT RS_BandPath(RS_FromPath('../../../submodules/sedona-testing/data/raster/test4.tiff')); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| //! Benchmarks for RS_FromPath UDF. | ||
| //! | ||
| //! RS_FromPath creates out-db rasters from file paths, so these benchmarks use | ||
| //! raster fixtures from the `sedona-testing` test module rather than synthetic input. | ||
|
|
||
| use std::{hint::black_box, sync::Arc}; | ||
|
|
||
| use arrow_array::{ArrayRef, StringArray}; | ||
| use arrow_schema::DataType; | ||
| use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; | ||
| use datafusion_expr::ScalarUDF; | ||
| use sedona_schema::datatypes::SedonaType; | ||
| use sedona_testing::{data::test_raster, testers::ScalarUdfTester}; | ||
|
|
||
| const SMALL_RASTER_FIXTURES: &[&str] = &[ | ||
| "test1.tiff", | ||
| "test2.tif", | ||
| "test3.tif", | ||
| "test4.tiff", | ||
| "test5.tiff", | ||
| ]; | ||
|
|
||
| fn raster_path_array(names: &[&str], rows: usize) -> ArrayRef { | ||
| assert!( | ||
| !names.is_empty(), | ||
| "benchmark fixture list must not be empty" | ||
| ); | ||
|
|
||
| let paths = names | ||
| .iter() | ||
| .map(|name| test_raster(name).unwrap()) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| let values = (0..rows) | ||
| .map(|index| paths[index % paths.len()].as_str()) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| Arc::new(StringArray::from(values)) | ||
| } | ||
|
|
||
| fn bench_rs_frompath(c: &mut Criterion) { | ||
| let udf: ScalarUDF = sedona_raster_gdal::rs_frompath_udf().into(); | ||
| let tester = ScalarUdfTester::new(udf, vec![SedonaType::Arrow(DataType::Utf8)]); | ||
|
|
||
| let single_small = raster_path_array(&["test4.tiff"], 1); | ||
| let mixed_small = raster_path_array(SMALL_RASTER_FIXTURES, SMALL_RASTER_FIXTURES.len()); | ||
| let batched_small = raster_path_array(SMALL_RASTER_FIXTURES, 256); | ||
|
|
||
| let mut group = c.benchmark_group("rs_frompath"); | ||
|
|
||
| group.throughput(Throughput::Elements(single_small.len() as u64)); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("fixtures", "single_small"), | ||
| &single_small, | ||
| |b, input| b.iter(|| black_box(tester.invoke_array(input.clone()).unwrap())), | ||
| ); | ||
|
|
||
| group.throughput(Throughput::Elements(mixed_small.len() as u64)); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("fixtures", "mixed_small"), | ||
| &mixed_small, | ||
| |b, input| b.iter(|| black_box(tester.invoke_array(input.clone()).unwrap())), | ||
| ); | ||
|
|
||
| group.throughput(Throughput::Elements(batched_small.len() as u64)); | ||
| group.bench_with_input( | ||
| BenchmarkId::new("fixtures", "batched_small"), | ||
| &batched_small, | ||
| |b, input| b.iter(|| black_box(tester.invoke_array(input.clone()).unwrap())), | ||
| ); | ||
|
|
||
| group.finish(); | ||
| } | ||
|
|
||
| criterion_group!(benches, bench_rs_frompath); | ||
| criterion_main!(benches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| use sedona_expr::function_set::FunctionSet; | ||
|
|
||
| /// Export the set of GDAL-backed functions defined in this crate. | ||
| pub fn default_function_set() -> FunctionSet { | ||
| let mut function_set = FunctionSet::new(); | ||
| function_set.insert_scalar_udf(crate::rs_frompath::rs_frompath_udf()); | ||
| function_set | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.