Skip to content

Commit

Permalink
feat: improve generated column names for methods receiving intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist authored and gforsyth committed Oct 20, 2023
1 parent 09881b0 commit c319ed3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ibis/expr/operations/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ def __init__(self, value, dtype):

@property
def name(self):
if self.dtype.is_interval():
return f"{self.value!r}{self.dtype.unit.short}"
return repr(self.value)


Expand Down
4 changes: 2 additions & 2 deletions ibis/expr/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,9 @@ def _binop(op_class: type[ops.Binary], left: ir.Value, right: ir.Value) -> ir.Va
>>> import ibis.expr.operations as ops
>>> expr = _binop(ops.TimeAdd, ibis.time("01:00"), ibis.interval(hours=1))
>>> expr
TimeAdd(datetime.time(1, 0), 1): datetime.time(1, 0) + 1 h
TimeAdd(datetime.time(1, 0), 1h): datetime.time(1, 0) + 1 h
>>> _binop(ops.TimeAdd, 1, ibis.interval(hours=1))
TimeAdd(datetime.time(0, 0, 1), 1): datetime.time(0, 0, 1) + 1 h
TimeAdd(datetime.time(0, 0, 1), 1h): datetime.time(0, 0, 1) + 1 h
"""
try:
node = op_class(left, right)
Expand Down

0 comments on commit c319ed3

Please sign in to comment.