Skip to content

Commit

Permalink
fix: Add exception handling for invalid value to cast a comparison fi…
Browse files Browse the repository at this point in the history
…eld (#957)

* Add exception handling for invalid text for cast config parameter

* fix: Adjust the exception handling message

* Move and update exception handling
  • Loading branch information
helensilva14 committed Aug 28, 2023
1 parent 0fed588 commit 703ca75
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions third_party/ibis/ibis_addon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import ibis.expr.datatypes as dt
import ibis.expr.operations as ops
import parsy

from ibis.expr.types.generic import Value

Expand Down Expand Up @@ -42,8 +43,11 @@ def force_cast(self, target_type: dt.DataType) -> Value:
"""New method to force cast even if data type is the same.
Used to cast a value to itself in ComparisonFields for nuances in data types i.e. casting CHAR to VARCHAR which are both Ibis strings
"""
# validate
op = ops.Cast(self, to=target_type)
# validate target type
try:
op = ops.Cast(self, to=target_type)
except parsy.ParseError:
raise SyntaxError(f"'{target_type}' is an invalid datatype provided to cast a ComparisonField")

if op.to.is_geospatial():
from_geotype = self.type().geotype or "geometry"
Expand Down

0 comments on commit 703ca75

Please sign in to comment.