Skip to content

Commit

Permalink
Fixed small issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Jun 20, 2019
1 parent 72c8d6e commit 36c305b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions ibis/expr/api.py
Expand Up @@ -679,14 +679,14 @@ def cast(arg, target_type):
# noop case if passed type is the same
return arg

if (
target_type.lower() in ('geometry', 'geography')
and (
arg.type().geotype == target_type
or (arg.type().geotype is None and target_type == 'geometry')
)
):
return arg
if isinstance(op.to, (dt.Geography, dt.Geometry)):
from_geotype = arg.type().geotype
to_geotype = op.to.geotype
if (
from_geotype == to_geotype
or (from_geotype is None and to_geotype == 'geometry')
):
return arg

result = op.to_expr()
if not arg.has_name():
Expand Down
3 changes: 2 additions & 1 deletion ibis/expr/datatypes.py
Expand Up @@ -1568,7 +1568,8 @@ def can_cast_variadic(
# geo spatial data type
# cast between same type, used to cast from/to geometry and geography
@castable.register(Array, (Point, LineString, Polygon, MultiPolygon))
@castable.register((Point, LineString, Polygon, MultiPolygon), GeoSpatial)
@castable.register((Point, LineString, Polygon, MultiPolygon), Geometry)
@castable.register((Point, LineString, Polygon, MultiPolygon), Geography)
def can_cast_geospatial(source, target, **kwargs):
return True

Expand Down

0 comments on commit 36c305b

Please sign in to comment.