Skip to content

Commit

Permalink
fix(duckdb): gate geoalchemy import in duckdb geospatial
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth committed Dec 4, 2023
1 parent 0596b51 commit 8f012c4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ibis/backends/duckdb/registry.py
Expand Up @@ -6,7 +6,6 @@

import numpy as np
import sqlalchemy as sa
from geoalchemy2 import Geometry
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.functions import GenericFunction

Expand All @@ -29,6 +28,18 @@
)
from ibis.common.exceptions import UnsupportedOperationError

try:
from geoalchemy2 import Geometry

class Geometry_WKB(Geometry):
as_binary = "ST_AsWKB"

except ImportError:

class Geometry_WKB:
...


if TYPE_CHECKING:
from collections.abc import Mapping

Expand Down Expand Up @@ -56,10 +67,6 @@ def _round(t, op):
}


class Geometry_WKB(Geometry):
as_binary = "ST_AsWKB"


def _centroid(t, op):
arg = t.translate(op.arg)
return sa.func.st_centroid(arg, type_=Geometry_WKB)
Expand Down

0 comments on commit 8f012c4

Please sign in to comment.