CatalogConnection#

class swordfish.connection.CatalogConnection(impl)#

Manages connections to database catalogs.

Examples

>>> import swordfish as sf
>>> conn = sf.connect(catalog="catalog_name")
create_schema(name, partition, *, engine='OLAP', atomic='TRANS')#

Creates a new schema.

Parameters:
  • name (str) – The name of the schema to create.

  • partition (Partition) – Defines the partitioning type and scheme.

  • engine ({"OLAP", "TSDB", "PKEY"}, optional) – The storage engine type to use. Defaults to “OLAP”.

  • atomic ({"TRANS", "CHUNK"}, optional) –

    In cases of concurrent writes to the same partition, write conflicts can occur. Swordfish manages these conflicts through the atomic parameter set during schema creation, offering two modes:

    • ’TRANS’ (default): Write operations are terminated upon detecting a conflict, ensuring transaction atomicity. Users themselves must ensure that concurrent writes to the same partition are prevented.

    • ’CHUNK’: The system automatically handles conflicts and retries writes, but splits a single write operation into multiple transactions, which cannot guarantee overall atomicity.

Returns:

A Schema created based on the given parameters.

Return type:

Schema

Examples

>>> conn = sf.connect("catalog_name")
>>> conn.create_schema(name="my_schema", engine="OLAP",
...     partition=sf.Partition.range(sf.vector([0, 5, 10], type="INT")))
list_schemas()#

Lists all schemas available in the catalog.

Returns:

A list of the names of schemas.

Return type:

list of str

Examples

>>> conn.list_schemas()
exists_schema(name)#
Parameters:

name (str)

Return type:

bool

drop_schema(name)#

Drops the specified schema from the catalog.

Parameters:

name (str) – The name of the schema to drop.

schema(name)#

Retrieves a schema by name.

Parameters:

name (str) – The name of the schema to retrieve.

Returns:

The schema corresponding to the given name.

Return type:

Schema