ibis.literal

ibis.literal(value, type=None)

Create a scalar expression from a Python value.

Parameters:
value : some Python basic type

A Python value

type : ibis type or string, optional

An instance of ibis.expr.datatypes.DataType or a string indicating the ibis type of value. This parameter should only be used in cases where ibis’s type inference isn’t sufficient for discovering the type of value.

Returns:
literal_value : Literal

An expression representing a literal value

Examples

>>> import ibis
>>> x = ibis.literal(42)
>>> x.type()
int8
>>> y = ibis.literal(42, type='double')
>>> y.type()
double
>>> ibis.literal('foobar', type='int64')  # doctest: +ELLIPSIS
Traceback (most recent call last):
  ...
TypeError: Value 'foobar' cannot be safely coerced to int64