# Base Expression Types¶

These APIs are shared by both table and column expressions.

##  Expr ¶

Base expression class

### Methods¶

#### compile(self, limit=None, timecontext=None, params=None)¶

Compile to an execution target.

Parameters:

Name Type Description Default
limit int | None

An integer to effect a specific row limit. A value of None means "no limit". The default is in ibis/config.py.

None
timecontext TimeContext | None

Defines a time range of (begin, end). When defined, the execution will only compute result for data inside the time range. The time range is inclusive of both endpoints. This is conceptually same as a time filter. The time column must be named 'time' and should preserve across the expression. For example, if that column is dropped then execute will result in an error.

None
params Mapping[ValueExpr, Any] | None

Mapping of scalar parameter expressions to value

None

#### execute(self, limit='default', timecontext=None, params=None, **kwargs)¶

Execute an expression against its backend if one exists.

Parameters:

Name Type Description Default
limit int | str | None

An integer to effect a specific row limit. A value of None means "no limit". The default is in ibis/config.py.

'default'
timecontext TimeContext | None

Defines a time range of (begin, end). When defined, the execution will only compute result for data inside the time range. The time range is inclusive of both endpoints. This is conceptually same as a time filter. The time column must be named 'time' and should preserve across the expression. For example, if that column is dropped then execute will result in an error.

None
params Mapping[ValueExpr, Any] | None

Mapping of scalar parameter expressions to value

None

#### pipe(self, f, *args, **kwargs)¶

Compose f with self.

Parameters:

Name Type Description Default
f None

If the expression needs to be passed as anything other than the first argument to the function, pass a tuple with the argument name. For example, (f, 'data') if the function f expects a 'data' keyword

required
args Any

Positional arguments to f

()
kwargs Any

Keyword arguments to f

{}

Examples:

>>> import ibis
>>> t = ibis.table([('a', 'int64'), ('b', 'string')], name='t')
>>> f = lambda a: (a + 1).name('a')
>>> g = lambda a: (a * 2).name('a')
>>> result1 = t.a.pipe(f).pipe(g)
>>> result1
r0 := UnboundTable[t]
a int64
b string
a: r0.a + 1 * 2

>>> result2 = g(f(t.a))  # equivalent to the above
>>> result1.equals(result2)
True


Returns:

Type Description
Expr

Result type of passed function

#### verify(self)¶

Return True if expression can be compiled to its attached client.

DEPRECATED: verify is deprecated as of v2.0; call Expr.compile and catch TranslationError

#### visualize(self, format='svg')¶

Visualize an expression in the browser as an SVG image.

Parameters:

Name Type Description Default
format str

Image output format. These are specified by the graphviz Python library.

'svg'

Exceptions:

Type Description
ImportError

If graphviz is not installed.

Last update: February 3, 2022