From 0613ef10bdf29612d3cb64080f48c0969a164eb5 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:50:08 -0400 Subject: [PATCH] feat(api): make the `null` function deferrable --- ibis/common/tests/test_deferred.py | 10 ++++++++++ ibis/expr/types/generic.py | 1 + 2 files changed, 11 insertions(+) diff --git a/ibis/common/tests/test_deferred.py b/ibis/common/tests/test_deferred.py index 616eebb47097..56bc1efb4a45 100644 --- a/ibis/common/tests/test_deferred.py +++ b/ibis/common/tests/test_deferred.py @@ -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 ( @@ -297,6 +298,9 @@ def __init__(self, name, dtype): def __deferred_repr__(self): return f"" + def type(self): + return self.dtype + class UnaryMock(ValueMock): __slots__ = ("name", "arg") @@ -602,3 +606,9 @@ def test_deferred_namespace(table): def test_custom_deferred_repr(table): expr = _.x + table.a assert repr(expr) == "(_.x + )" + + +def test_null_deferrable(table): + result = ibis.null(_.a.type()).resolve(table).op() + expected = ibis.null(table.a.type()).op() + assert result == expected diff --git a/ibis/expr/types/generic.py b/ibis/expr/types/generic.py index f607ae9385d3..325950ebf72f 100644 --- a/ibis/expr/types/generic.py +++ b/ibis/expr/types/generic.py @@ -2399,6 +2399,7 @@ class NullColumn(Column, NullValue): @public +@deferrable def null(type: dt.DataType | str | None = None) -> Value: """Create a NULL scalar.