You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inconsistent behaviour for nullable vs non-null columns, this is caused by this expression in ibis_addon/api.py:
if op.to == self.type() and not op.to.is_timestamp():
# noop case if passed type is the same
return self
self.type() is an Ibis type expression that internally holds a value prefixed with ! for not-null columns, e.g. !string for String columns. op.to is always the nullable variant.
Because of this only nullable columns drop into the no-op branch and bypass a cast to string.
We could fix this with a simple workaround (aka hack) like this:
"""
+ def same_type(from_type, to_type) -> bool:
+ # The data type for Non-nullable columns if prefixed with "!", this is causing deviations
+ # between nullable and non-nullable columns. The second comparison below is catering for this.
+ return bool(
+ from_type == to_type
+ or str(from_type).lstrip("!") == str(to_type).lstrip("!")
+ )
+
# validate
op = ops.Cast(self, to=target_type)
- if op.to == self.type() and not op.to.is_timestamp():
+ if same_type(op.to, self.type()) and not op.to.is_timestamp():
# noop case if passed type is the same
The text was updated successfully, but these errors were encountered:
I think op.to would be equivalent to the target_type provided in the function parameters: def cast(self, target_type: dt.DataType) -> Value
So I think the issue lies within our cast to 'string' when we do row hash validation here rather than to '!string ' if the original column is required. We assume that the cast will account for checking the same type regardless of nullability.
Due to this, I think your approach makes the most sense.
Inconsistent behaviour for nullable vs non-null columns, this is caused by this expression in
ibis_addon/api.py
:self.type()
is an Ibis type expression that internally holds a value prefixed with!
for not-null columns, e.g.!string
for String columns.op.to
is always the nullable variant.Because of this only nullable columns drop into the no-op branch and bypass a cast to string.
We could fix this with a simple workaround (aka hack) like this:
The text was updated successfully, but these errors were encountered: