Skip to content

SQL Backend Base Classes

BaseSQLBackend (BaseBackend)

Base backend class for backends that compile to SQL.

Methods

compile(self, expr, limit=None, params=None, timecontext=None)

Compille an Ibis expression.

Parameters

expr Ibis expression limit For expressions yielding result sets; retrieve at most this number of values/rows. Overrides any limit already set on the expression. params Named unbound parameters timecontext Additional information about data source time boundaries

Returns

Any The output of compilation. The type of this value depends on the backend.

execute(self, expr, params=None, limit='default', **kwargs)

Compile and execute an Ibis expression.

Compile and execute Ibis expression using this backend client interface, returning results in-memory in the appropriate object type

Parameters

expr Ibis expression limit For expressions yielding result sets; retrieve at most this number of values/rows. Overrides any limit already set on the expression. params Named unbound parameters kwargs Backend specific arguments. For example, the clickhouse backend uses this to receive external_tables as a dictionary of pandas DataFrames.

Returns

DataFrame | Series | Scalar * Table: pandas.DataFrame * Column: pandas.Series * Scalar: Python scalar value

explain(self, expr, params=None)

Explain an expression.

Return the query plan associated with the indicated expression or SQL query.

Returns

str Query plan

has_operation(operation) classmethod

Return whether the backend implements support for operation.

Parameters

operation A class corresponding to an operation.

Returns

bool Whether the backend implements the operation.

Examples

import ibis import ibis.expr.operations as ops ibis.sqlite.has_operation(ops.ArrayIndex) False ibis.postgres.has_operation(ops.ArrayIndex) True

raw_sql(self, query, results=False)

Execute a query string.

Could have unexpected results if the query modifies the behavior of the session in a way unknown to Ibis; be careful.

Parameters

query DML or DDL statement

Returns

Any Backend cursor

sql(self, query)

Convert a SQL query to an Ibis table expression.

Parameters

query SQL string

Returns

Table Table expression

table(self, name, database=None)

Construct a table expression.

Parameters

name Table name database Database name

Returns

Table Table expression


Last update: March 1, 2022