Skip to content

Commit

Permalink
feat(api): make the null function deferrable
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 22, 2024
1 parent e0436aa commit 0613ef1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ibis/common/tests/test_deferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
from pytest import param

import ibis
from ibis.common.bases import Slotted
from ibis.common.collections import FrozenDict
from ibis.common.deferred import (
Expand Down Expand Up @@ -297,6 +298,9 @@ def __init__(self, name, dtype):
def __deferred_repr__(self):
return f"<column[{self.dtype}]>"

def type(self):
return self.dtype


class UnaryMock(ValueMock):
__slots__ = ("name", "arg")
Expand Down Expand Up @@ -602,3 +606,9 @@ def test_deferred_namespace(table):
def test_custom_deferred_repr(table):
expr = _.x + table.a
assert repr(expr) == "(_.x + <column[int]>)"


def test_null_deferrable(table):
result = ibis.null(_.a.type()).resolve(table).op()
expected = ibis.null(table.a.type()).op()
assert result == expected
1 change: 1 addition & 0 deletions ibis/expr/types/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,7 @@ class NullColumn(Column, NullValue):


@public
@deferrable
def null(type: dt.DataType | str | None = None) -> Value:
"""Create a NULL scalar.
Expand Down

0 comments on commit 0613ef1

Please sign in to comment.