Skip to content

Commit 8f012c4

Browse files
committed
fix(duckdb): gate geoalchemy import in duckdb geospatial
1 parent 0596b51 commit 8f012c4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ibis/backends/duckdb/registry.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import numpy as np
88
import sqlalchemy as sa
9-
from geoalchemy2 import Geometry
109
from sqlalchemy.ext.compiler import compiles
1110
from sqlalchemy.sql.functions import GenericFunction
1211

@@ -29,6 +28,18 @@
2928
)
3029
from ibis.common.exceptions import UnsupportedOperationError
3130

31+
try:
32+
from geoalchemy2 import Geometry
33+
34+
class Geometry_WKB(Geometry):
35+
as_binary = "ST_AsWKB"
36+
37+
except ImportError:
38+
39+
class Geometry_WKB:
40+
...
41+
42+
3243
if TYPE_CHECKING:
3344
from collections.abc import Mapping
3445

@@ -56,10 +67,6 @@ def _round(t, op):
5667
}
5768

5869

59-
class Geometry_WKB(Geometry):
60-
as_binary = "ST_AsWKB"
61-
62-
6370
def _centroid(t, op):
6471
arg = t.translate(op.arg)
6572
return sa.func.st_centroid(arg, type_=Geometry_WKB)

0 commit comments

Comments
 (0)