CatalogConnection#

class swordfish.connection.CatalogConnection(impl)#

Manages connections to database catalogs.

示例

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

Creates a new schema.

参数:
  • 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.

返回:

A Schema created based on the given parameters.

返回类型:

Schema

示例

>>> 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.

返回:

A list of the names of schemas.

返回类型:

list of str

示例

>>> conn.list_schemas()
exists_schema(name)#
参数:

name (str)

返回类型:

bool

drop_schema(name)#

Drops the specified schema from the catalog.

参数:

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

schema(name)#

Retrieves a schema by name.

参数:

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

返回:

The schema corresponding to the given name.

返回类型:

Schema