Skip to content

Commit

Permalink
fix(trino): fix integer to timestamp casting
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-kwitt authored and cpcloud committed Dec 27, 2022
1 parent ce5d726 commit 49321a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ibis/backends/tests/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,15 @@ def test_timestamp_extract_milliseconds_with_big_value(con):
assert result == 333


@pytest.mark.notimpl(["bigquery", "datafusion", "mssql", "trino"])
@pytest.mark.notimpl(["bigquery", "datafusion", "mssql"])
def test_integer_cast_to_timestamp_column(backend, alltypes, df):
expr = alltypes.int_col.cast("timestamp")
expected = pd.to_datetime(df.int_col, unit="s").rename(expr.get_name())
result = expr.execute()
backend.assert_series_equal(result, expected)


@pytest.mark.notimpl(["bigquery", "datafusion", "pyspark", "mssql", "trino"])
@pytest.mark.notimpl(["bigquery", "datafusion", "pyspark", "mssql"])
def test_integer_cast_to_timestamp_scalar(alltypes, df):
expr = alltypes.int_col.min().cast("timestamp")
result = expr.execute()
Expand Down
2 changes: 2 additions & 0 deletions ibis/backends/trino/compiler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import sqlalchemy as sa
from trino.sqlalchemy.datatype import JSON
from trino.sqlalchemy.dialect import TrinoDialect

Expand All @@ -14,6 +15,7 @@ class TrinoSQLExprTranslator(AlchemyExprTranslator):
_rewrites = AlchemyExprTranslator._rewrites.copy()
_type_map = AlchemyExprTranslator._type_map.copy()
_has_reduction_filter_syntax = True
integer_to_timestamp = sa.func.from_unixtime
_forbids_frame_clause = (
*AlchemyExprTranslator._forbids_frame_clause,
ops.Lead,
Expand Down

0 comments on commit 49321a6

Please sign in to comment.