Skip to main content

engines.Connection

Named Arrow tables, and the engine that runs plans over them.

Usage

Source

engines.Connection(engine="duckdb")

sverify.connect() makes one; the class is for type hints.

  • create(name, schema, rows) and put(name, table) add a table; get(name) is the table as given, the input of every engine, and rows(name) its rows. A table may instead be one DuckDB reads where it is: a table format’s files (Scan), or a table DuckDB holds, such as a view’s state (Resident).
  • table(name) is an Ibis table bound to it, through an Ibis DuckDB backend that views the Arrow tables. Contracts find a table’s data and metadata through it, and Ibis’s own execute works on it; con.table(name).get_backend() is the backend, for SQL of your own.
  • engine runs plans (sverify.engines.run) unless a call names another.
  • The DataFusion engine runs on a private DataFusion session holding the same tables (with the functions Ibis’s DataFusion SQL calls), created on first use.

Parameters

engine: Engine = "duckdb"
"duckdb", "polars" or "datafusion". Default: "duckdb".

Attributes

engine: Engine

The engine that runs plans unless a call names another.

arrow: MutableMapping[str, pa.Table]

Deprecated: the tables by name, as Arrow tables; get, rows and put read and write them.

ibis: Any

Deprecated: the Ibis DuckDB backend the bound tables read through; table(name).get_backend() is the same backend.

datafusion: Any
Deprecated: the DataFusion session, an internal of the DataFusion engine (#413).

Raises

ValueError
engine is unknown.

Attributes

Name Description
arrow Deprecated: the tables by name, as Arrow tables.
ibis Deprecated: the Ibis DuckDB backend the bound tables read through.

arrow

Deprecated: the tables by name, as Arrow tables.

arrow: MutableMapping[str, pa.Table]


ibis

Deprecated: the Ibis DuckDB backend the bound tables read through.

ibis: Any

Methods

Name Description
create() Add table name with schema (Ibis or Arrow) and rows (tuples
drop() Remove table name; nothing happens if there is none.
get() Table name as it is held: an Arrow table, or a table DuckDB
has() Whether the connection has a table name.
put() Add or replace table name, with doubles as the model has them
rows() The rows of table name, as tuples in schema order, in the
schema() The Arrow schema of table name.
table() Table name as an Ibis table bound to the connection. Its schema is

create()

Add table name with schema (Ibis or Arrow) and rows (tuples

Usage

Source

create(name, schema, rows=())

in schema order), replacing any table of that name.

Parameters
name: str

The table’s name.

schema: ibis.Schema | pa.Schema

Its schema, as an Ibis or Arrow schema. An Arrow schema can mark columns NOT NULL (nullable=False), which contracts use.

rows: Iterable[tuple] = ()
Tuples in the schema’s column order. Default: no rows.

drop()

Remove table name; nothing happens if there is none.

Usage

Source

drop(name)

get()

Table name as it is held: an Arrow table, or a table DuckDB

Usage

Source

get(name)

reads where it is (Scan, Resident).


has()

Whether the connection has a table name.

Usage

Source

has(name)

put()

Add or replace table name, with doubles as the model has them

Usage

Source

put(name, table)

(canonical: one zero, one NaN).

Large and view strings become plain strings, the one string type of Substrait plans. The table is registered with the Ibis backend and, once it exists, the DataFusion session.

Parameters
name: str

The table’s name.

table: pa.Table | Native
Its contents, or a table DuckDB reads where it is (a Scan of files, a Resident table), which the Ibis backend views.

rows()

The rows of table name, as tuples in schema order, in the

Usage

Source

rows(name)

table’s order.

Raises
KeyError
The connection has no table name.

schema()

The Arrow schema of table name.

Usage

Source

schema(name)

table()

Table name as an Ibis table bound to the connection. Its schema is

Usage

Source

table(name)

the Arrow table’s, nullability included (DuckDB’s view of it drops NOT NULL, which contracts read).

Parameters
name: str
A table of the connection.
Returns
ir.Table
The bound Ibis table.
Raises
KeyError
The connection has no table name.