-
Notifications
You must be signed in to change notification settings - Fork 187
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
Support Spatial Types for PostGIS #1927
Conversation
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
✅ Deploy Preview for dlt-hub-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
# Conflicts: # poetry.lock # pyproject.toml
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @Pipboyguy
I have a couple of questions, please see my comments.
# Conflicts: # .github/workflows/test_doc_snippets.yml # poetry.lock
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is really good!
- my suggestion is that we drop wkb and just keep wkb_text. also move shapely to dev dependencies
- IMO csv with WKT and WKB_HEX should work! did you try it? it'd be hard to understand why not....
) and not file_path.endswith("insert_values"): | ||
# Only insert_values load jobs supported for geom types. | ||
# TODO: This isn't actually true, can make it work with geoarrow! | ||
raise TerminalValueError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it really true? if column is text and contains WKT data it should get inserted. did you try it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added csv loader cases to the geo test, and it all passes. Your intuition was entirely correct!
dlt/common/data_writers/escape.py
Outdated
@@ -56,7 +67,12 @@ def escape_postgres_literal(v: Any) -> Any: | |||
if isinstance(v, (list, dict)): | |||
return _escape_extended(json.dumps(v)) | |||
if isinstance(v, bytes): | |||
return f"'\\x{v.hex()}'" | |||
if is_valid_wkb(v): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very impractical :/ we have a dependence on shapely and there may be false positives (there are no magic numbers in wkb). passing expected type to escape...literal will slow this down
we could use a special binary type but user would need to wrap binary anyway. so my take is to drop wkb
and just keep wkb_hex
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, removed wkb support, will update docs too
# Conflicts: # poetry.lock
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
Signed-off-by: Marcel Coetzee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
This PR adds support for PostGIS GEOMETRY type in PostgreSQL. It introduces a logical type for GEOMETRY on binary or text fields.
Users can declare geometry columns via the
postgres_adapter
, enabling direct insertion from WKT, WKB and WKB hex representations, in addition to GeoPandas integration with automatic geometry column detection and conversion.Related Issues
Limitations
LinearRing
only works with wkb type (python binary type)Typical usage pattern: