Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ibis/expr/datatypes/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from collections.abc import Mapping, Sequence
from functools import partial
from operator import attrgetter
from typing import Any
from typing import Any, NoReturn

import toolz
from public import public

import ibis.expr.datatypes as dt
from ibis.common.collections import frozendict
from ibis.common.deferred import Deferred
from ibis.common.dispatch import lazy_singledispatch
from ibis.common.exceptions import IbisTypeError, InputTypeError
from ibis.common.numeric import normalize_decimal
Expand All @@ -37,6 +38,16 @@ def infer(value: Any) -> dt.DataType:
)


@infer.register(Deferred)
def infer_deferred(value: Deferred) -> NoReturn:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for my ignorance: is there somewhere I can refer to to get an idea of circumstances that cause inference to be triggered? seems like its not when building a Deferred which makes sense, so presumably its when incorporating a Deferred into an expression bound to a concrete table or column?

raise TypeError(
"Cannot infer the type of a Deferred value. "
"You will need to use a bound value instead. "
"For example, if you have `ibis._.my_col + 5`, "
"you will need to replace this with `my_table.my_col + 5`."
)


# TODO(kszucs): support NamedTuples and dataclasses instead of OrderedDict
# which should trigger infer_map instead
@infer.register(collections.OrderedDict)
Expand Down
Loading