-
Notifications
You must be signed in to change notification settings - Fork 610
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
fix(datatypes): proper handling of srid in geospatial datatypes #9519
Conversation
This isn't hitting the codepath because the round trip assertion first produces a SQLGlot type, but without the SRID, which is incorrect, and then converts that back to an Ibis type that doesn't have the SRID (because it wasn't produced). |
You have to also adjust the |
I added the srid in the
Clearly I'm missing something here, but not sure what the syntax is to be ale to pass the srid, if method := getattr(cls, f"_from_sqlglot_{typecode.name}", None):
dtype = method(*typ.expressions) |
Pushed up a few changes to get this working for both geometry and geography, was a bit gnarlier than I thought. The issue was that all the Point/MultiPoint etc types need to be handled separately so that they can be passed as a |
ibis/tests/strategies.py
Outdated
return st.builds( | ||
dt.GeoSpatial, | ||
geotype=st.just("geometry"), | ||
nullable=nullable, | ||
srid=st.just(srid), | ||
srid=st.one_of(st.just(None), st.just(4321)), |
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 this to build the two separate strategies? If so, pretty neat : )
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.
Yep!
Looks like I broke a few things. Have an idea how to fix it, but checking out for the day, happy 4th! |
Co-authored-by: Naty Clementi <natyclementi@gmail.com>
Gonna add the test case from the original issue here as well! |
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.
@ncclementi This LGTM if you want to give it another look!
@@ -27,8 +27,6 @@ | |||
typecode.ENUM16: dt.String, | |||
typecode.FLOAT: dt.Float32, | |||
typecode.FIXEDSTRING: dt.String, | |||
typecode.GEOMETRY: partial(dt.GeoSpatial, geotype="geometry"), |
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.
Small question, we don't need these ones any more because we will always git this path
method := getattr(cls, f"_from_sqlglot_{typecode.name}", None)
in to_ibis()
now?
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.
Yes, that's the reason, but it was that way before this PR too.
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, thanks for taking this across the line, looks like it got a bit gnarly.
I left a comment with one question, but it's mostly for my understanding.
Thanks @ncclementi! Merging. |
This is still broken, some how the srid value is not being passed properly to
_from_sqlglot_GEOMETRY
, I think it's because I need to change something infrom_ibis
too, but not sure how to handle passing the param.I'm constructing well, the ibis_type in the test, I see
But when this is passed to
SqlglotType.from_ibis(ibis_type)
I'm missing somthing that I don't quite pin point yet.Any comments are welcome