Skip to content

Commit

Permalink
feat(impala): epoch_days
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 24, 2024
1 parent 36d5e05 commit 1502091
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 11 additions & 1 deletion ibis/backends/sql/compilers/impala.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class ImpalaCompiler(SQLGlotCompiler):
ops.ArrayPosition,
ops.Array,
ops.Covariance,
ops.DateDelta,
ops.ExtractDayOfYear,
ops.Levenshtein,
ops.Map,
Expand Down Expand Up @@ -314,5 +313,16 @@ def visit_Sign(self, op, *, arg):
return self.cast(sign, dtype)
return sign

def visit_DateDelta(self, op, *, left, right, part):
if not isinstance(part, sge.Literal):
raise com.UnsupportedOperationError(

Check warning on line 318 in ibis/backends/sql/compilers/impala.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/sql/compilers/impala.py#L318

Added line #L318 was not covered by tests
"Only literal `part` values are supported for date delta"
)
if part.this != "day":
raise com.UnsupportedOperationError(

Check warning on line 322 in ibis/backends/sql/compilers/impala.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/sql/compilers/impala.py#L322

Added line #L322 was not covered by tests
f"Only 'day' part is supported for date delta in the {self.dialect} backend"
)
return self.f.datediff(left, right)


compiler = ImpalaCompiler()
7 changes: 3 additions & 4 deletions ibis/backends/tests/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1967,8 +1967,7 @@ def test_timestamp_precision_output(con, ts, scale, unit):


@pytest.mark.notimpl(
["dask", "datafusion", "druid", "impala", "pandas"],
raises=com.OperationNotDefinedError,
["dask", "datafusion", "druid", "pandas"], raises=com.OperationNotDefinedError
)
@pytest.mark.parametrize(
("start", "end", "unit", "expected"),
Expand All @@ -1991,7 +1990,7 @@ def test_timestamp_precision_output(con, ts, scale, unit):
raises=com.OperationNotDefinedError,
),
pytest.mark.notimpl(
["exasol", "polars", "sqlite", "oracle"],
["exasol", "polars", "sqlite", "oracle", "impala"],
raises=com.OperationNotDefinedError,
),
],
Expand All @@ -2015,7 +2014,7 @@ def test_timestamp_precision_output(con, ts, scale, unit):
reason="timestampdiff rounds after subtraction and mysql doesn't have a date_trunc function",
),
pytest.mark.notimpl(
["exasol", "polars", "sqlite", "oracle"],
["exasol", "polars", "sqlite", "oracle", "impala"],
raises=com.OperationNotDefinedError,
),
],
Expand Down

0 comments on commit 1502091

Please sign in to comment.