Skip to content

Commit

Permalink
Update datafusion git tag to fix DenseUnion (#951)
Browse files Browse the repository at this point in the history
Ref apache/datafusion#13797.

This is now working for geometries!

```
SELECT ST_GeomFromText('LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)');
```

```
---- udf::native::io::wkt::test::test stdout ----
+----------------------------------------------------------------------------------------------------+
| st_geomfromtext(Utf8("LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)")) |
+----------------------------------------------------------------------------------------------------+
| {=[{x: -71.160281, y: 42.258729}, {x: -71.160837, y: 42.259113}, {x: -71.161144, y: 42.25932}]}    |
+----------------------------------------------------------------------------------------------------+
```

🚀
  • Loading branch information
kylebarron authored Dec 16, 2024
1 parent 5b69dac commit 815f62c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 131 deletions.
45 changes: 23 additions & 22 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/geodatafusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rust-version = "1.82"


[dependencies]
datafusion = { git = "https://github.com/apache/datafusion", rev = "03e39da62e403e064d21b57e9d6c200464c03749" }
datafusion = { git = "https://github.com/kylebarron/datafusion", rev = "170432e3179ed72f413ffcd4d7edfe0007db296d" }
arrow = { version = "53.3", features = ["ffi"] }
arrow-array = { version = "53.3", features = ["chrono-tz"] }
arrow-buffer = "53.3"
Expand Down
1 change: 0 additions & 1 deletion rust/geodatafusion/src/udf/native/io/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Geometry Input and Output
mod geohash;
mod union_example;
mod wkb;
mod wkt;

Expand Down
95 changes: 0 additions & 95 deletions rust/geodatafusion/src/udf/native/io/union_example.rs

This file was deleted.

14 changes: 2 additions & 12 deletions rust/geodatafusion/src/udf/native/io/wkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::any::Any;
use std::sync::OnceLock;

use arrow::array::AsArray;
use arrow_array::Array;
use arrow_schema::DataType;
use datafusion::logical_expr::scalar_doc_sections::DOC_SECTION_OTHER;
use datafusion::logical_expr::{
Expand Down Expand Up @@ -131,14 +130,7 @@ fn geom_from_text_impl(args: &[ColumnarValue]) -> GeoDataFusionResult<ColumnarVa
.unwrap();
let wkt_arr = WKTArray::new(array.as_string::<i32>().clone(), Default::default());
let native_arr = read_wkt(&wkt_arr, CoordType::Separated, false)?;
dbg!("native_arr");

let arrow_arr = native_arr.to_array_ref();
if let DataType::Union(_fields, mode) = arrow_arr.data_type() {
dbg!(mode);
}

Ok(arrow_arr.into())
Ok(native_arr.to_array_ref().into())
}

#[cfg(test)]
Expand All @@ -153,8 +145,6 @@ mod test {
register_native(&ctx);

let out = ctx.sql("SELECT ST_GeomFromText('LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)');").await.unwrap();
// TODO: fix this error upstream
// https://github.com/apache/datafusion/issues/13762
out.show().await.unwrap_err();
out.show().await.unwrap();
}
}

0 comments on commit 815f62c

Please sign in to comment.