ibis icon indicating copy to clipboard operation
ibis copied to clipboard

fix(duckdb): use simple GEOMETRY type for all geospatial data (#10324)

Open anjakefala opened this issue 1 year ago • 1 comments

Ensure compatibility with DuckDB's implementation of geospatial types.

I would love to add tests. Which is the appropriate test file?

  • [ ] added tests

Description of changes

In https://github.com/ibis-project/ibis/issues/10324 the temporary table generated the incorrect SQL definition of GEOMETRY(POINT) instead of the simple GEOMETRY. This ensures that the simple GEOMETRY will be used for all geospatial types.

Issues closed

  • Resolves #10324

anjakefala avatar Oct 18 '24 22:10 anjakefala

Thanks @anjakefala !

Since this change is specific to the DuckDB backend, tests should go in ibis/backends/DuckDB/tests/

For this particular fix, either test_datatypes.py or test_geospatial.py work -- whichever feels like a better fit to you!

gforsyth avatar Oct 19 '24 00:10 gforsyth

@anjakefala Ping on this! Still interested in adding a test?

cpcloud avatar Oct 22 '24 13:10 cpcloud

@cpcloud Yes, sorry! I'm travelling soon, but was planning to add tests today!

anjakefala avatar Oct 22 '24 18:10 anjakefala

Hey @gforsyth and @cpcloud!

I added a simple test. But unlike with the issue, this test passes on main. So there is something about the fetched example that lead to the issue. I'm investigating that currently to see if I can reproduce it in an example. I pushed the small test I had so far.

Would it make sense for me to add tests checking that all the geometry types were being compiled as GEOMETRY? Do you write tests at the level of compiled sql?

anjakefala avatar Oct 22 '24 23:10 anjakefala

It seems that the example zone already contained a geom column. Reproducing the scenario still unfortunately passed on main:

 565                                                                                                                                                                                  
 566 def test_cache_geometry(con):                                                                                                                                                    
 567     # ibis issue #10324                                                                                                                                                          
 568     data = ibis.memtable({"x": [1, 3], "y": [2, 4]})                                                                                                                             
 569     data = data.mutate(geom=data.x.point(data.y))                                                                                                                                
 570     data = data.mutate(geom=data.x.point(data.y)).cache()                                                                                                                        
 571     result = data.execute()                                                                                                                                                      
 572     assert result['geom'].iloc[0] == shapely.Point(1, 2)  

anjakefala avatar Oct 23 '24 00:10 anjakefala

Your test fails for me on main with the same error reported by the user. Are you sure you were running your test against main?

cpcloud avatar Oct 23 '24 12:10 cpcloud

@cpcloud HUH. Okay, then. Carry on.

anjakefala avatar Oct 24 '24 03:10 anjakefala

Thanks!

cpcloud avatar Oct 24 '24 11:10 cpcloud