-
Notifications
You must be signed in to change notification settings - Fork 2
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
Expose upstream schema #18
Comments
Oh, interesting. So geoarrow-rs defines new types of array for each of the geometry types? To answer your question: yes it is totally doable to expose the original type of a column in a query response. A sidenote: for Postgres, response types are returned just as an In this scenario, This does add another step into the data pipeline, but it would be the easiest to implement. The title of the post suggests something different: to dynamically specify how certain database type have to be converted into arrow types. For the record, this is much harder to do, since it needs to plug into my machinery of mapping types and providing data converters. |
Yeah, geoarrow-rs follows the GeoArrow specification. GeoArrow follows the same "Simple Features" spec as PostGIS, so GeoArrow also has Point, LineString, Polygon, etc types like PostGIS, but they're stored differently. PostGIS has a custom internal format IIRC while yes a two-dimensional
PostGIS data comes over the wire as Well-Known Binary, which packs each row into a well-specified binary format. This would come across as an Arrow BinaryArray. I'm not suggesting that
Yeah... I'm a little hazy on those details. I think sqlx might sometime make those additional queries transparently to the user.
I don't think I need anything truly dynamic. |
One potential way to do this, though it would have less type safety, would be to include upstream metadata on the Arrow field metadata. Then you wouldn't need to change the API presumably. |
Oh this is great! So I wouldn't say that this is less type-safe. I also like this approach because it also works with any other Postgres extension or built-in non-trivial type. It makes |
Ignore this, I was wrong. This is handled by https://github.com/sfackler/rust-postgres/blob/master/tokio-postgres/src/prepare.rs#L134-L186 |
Implemented in e4fd3ca @kylebarron, please take a look and verify that this covers your use case. |
👋 I saw you were looking for feedback and I was curious whether you have support for or are interested in exposing support for user-defined data types? In particular, I'm working on building out support for geospatial in arrow in https://github.com/geoarrow/geoarrow-rs. We have a working but limited implementation that reads from PostGIS databases. It directly connects to
sqlx
, and it would be great to use a library like yours that focuses on converting database tables -> arrow. But we need to be able to access the type name, which is"geometry"
or"geography"
on a PostGIS column.I haven't looked through your API yet, but I think one way this could work is if you exposed both the Postgres schema and the inferred Arrow schema? Because then geoarrow could access the upstream schema and know that the BinaryArray column actually represents geospatial data.
The text was updated successfully, but these errors were encountered: