Skip to content

Commit

Permalink
fix(snowflake): don't always insert a cast
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jan 18, 2023
1 parent 7ae6e25 commit ee8817b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ibis/backends/base/sql/alchemy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ def _cast(t, op):

if typ.is_json() and not t.native_json_type:
return sa_arg

ignore_cast_types = t._ignore_cast_types
if ignore_cast_types and isinstance(typ, ignore_cast_types):
return sa_arg
return sa.cast(sa_arg, sa_type)


Expand Down
1 change: 1 addition & 0 deletions ibis/backends/base/sql/alchemy/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AlchemyExprTranslator(ExprTranslator):
integer_to_timestamp = sa.func.to_timestamp
native_json_type = True
_always_quote_columns = False
_ignore_cast_types = ()

_require_order_by = (
ops.DenseRank,
Expand Down
2 changes: 2 additions & 0 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import toolz
from snowflake.sqlalchemy import URL

import ibis.expr.datatypes as dt
import ibis.expr.operations as ops
import ibis.expr.schema as sch
from ibis.backends.base.sql.alchemy import (
Expand Down Expand Up @@ -38,6 +39,7 @@ class SnowflakeExprTranslator(AlchemyExprTranslator):
ops.Lead,
)
_require_order_by = (*AlchemyExprTranslator._require_order_by, ops.Reduction)
_ignore_cast_types = (dt.Map, dt.Array)


class SnowflakeCompiler(AlchemyCompiler):
Expand Down

0 comments on commit ee8817b

Please sign in to comment.