Skip to content

Commit

Permalink
feat(pyspark): add DateDiff operation
Browse files Browse the repository at this point in the history
  • Loading branch information
tokoko authored and cpcloud committed Mar 27, 2023
1 parent af9a2c8 commit bfd6109
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 5 additions & 2 deletions ibis/backends/pyspark/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,8 +1536,11 @@ def compile_date_sub(t, op, **kwargs):

@compiles(ops.DateDiff)
def compile_date_diff(t, op, **kwargs):
raise com.UnsupportedOperationError(
'PySpark backend does not support DateDiff as there is no timedelta type.'
left = t.translate(op.left, **kwargs)
right = t.translate(op.right, **kwargs)

return F.concat(F.lit("INTERVAL '"), F.datediff(left, right), F.lit("' DAY")).cast(
pt.DayTimeIntervalType(pt.DayTimeIntervalType.DAY, pt.DayTimeIntervalType.DAY)
)


Expand Down
5 changes: 0 additions & 5 deletions ibis/backends/tests/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,11 +855,6 @@ def convert_to_offset(x):
lambda t, _: t.timestamp_col.dt.floor('d') - date_value,
id='date-subtract-date',
marks=[
pytest.mark.notimpl(
["pyspark"],
raises=com.UnsupportedOperationError,
reason="PySpark backend does not support DateDiff as there is no timedelta type.",
),
pytest.mark.notimpl(["bigquery"], raises=com.OperationNotDefinedError),
pytest.mark.notimpl(
["druid"],
Expand Down

0 comments on commit bfd6109

Please sign in to comment.