Closed ncclementi closed 2 weeks ago
@cpcloud you mentioned the to_sqlglot
method in the compiler would be a good place to fit in the logic to load the spatial extension, but we don't have that method in the duckdb compiler. In the base compiler under backends/sql/compiler.py
I only see this
I think Ideally we should be able to load the spatial extension when the casting is to
a geometry type.
The amgic happens here, but here there is no con
to be able to load the extension.
We definitely can't and shouldn't load extensions in the compiler, that would mean you could never use the compiler without having already connected to DuckDB.
This has to happen in the backend, just before execution.
You can do this in a _to_sqlglot
override in the duckdb Backend
class:
def _to_sqlglot(self, ...):
if any geospatial types:
self.load_extensions(["geospatial"]) # don't remember the exact API
return super()._to_sqlglot(...)
What happened?
What version of ibis are you using?
main
What backend(s) are you using, if any?
duckdb
Relevant log output
No response
Code of Conduct