ApdbCassandraSchema

class lsst.dax.apdb.ApdbCassandraSchema(session: cassandra.cluster.Session, keyspace: str, schema_file: str, schema_name: str = 'ApdbSchema', prefix: str = '', time_partition_tables: bool = False, use_insert_id: bool = False)

Bases: lsst.dax.apdb.ApdbSchema

Class for management of APDB schema.

Parameters:
session : cassandra.cluster.Session

Cassandra session object

schema_file : str

Name of the YAML schema file.

schema_name : str, optional

Name of the schema in YAML files.

prefix : str, optional

Prefix to add to all schema elements.

time_partition_tables : bool

If True then schema will have a separate table for each time partition.

Attributes Summary

has_insert_id Whether insert ID tables are to be used (bool).

Methods Summary

apdbColumnNames(table_name, …) Return a list of columns names for a table as defined in APDB schema.
clusteringColumns(table_name, …) Return a list of columns used for clustering.
column_dtype(felis_type) Return Pandas data type for a given Felis column type.
getColumnMap(table_name, …) Returns mapping of column names to Column definitions.
makeSchema(drop, part_range, int], None] = None) Create or re-create all tables.
partitionColumns(table_name, …) Return a list of columns used for table partitioning.
tableName(table_name, …) Return Cassandra table name for APDB table.

Attributes Documentation

has_insert_id

Whether insert ID tables are to be used (bool).

Methods Documentation

apdbColumnNames(table_name: lsst.dax.apdb.apdbSchema.ApdbTables | lsst.dax.apdb.apdbCassandraSchema.ExtraTables[lsst.dax.apdb.apdbSchema.ApdbTables, lsst.dax.apdb.apdbCassandraSchema.ExtraTables]) → List[str]

Return a list of columns names for a table as defined in APDB schema.

Parameters:
table_name : ApdbTables or ExtraTables

Enum for a table in APDB schema.

Returns:
columns : list of str

Names of regular columns in the table.

clusteringColumns(table_name: lsst.dax.apdb.apdbSchema.ApdbTables | lsst.dax.apdb.apdbCassandraSchema.ExtraTables[lsst.dax.apdb.apdbSchema.ApdbTables, lsst.dax.apdb.apdbCassandraSchema.ExtraTables]) → List[str]

Return a list of columns used for clustering.

Parameters:
table_name : ApdbTables

Table name in APDB schema

Returns:
columns : list of str

Names of columns for used for clustering.

column_dtype(felis_type: Type[felis.types.FelisType]) → Union[type, str]

Return Pandas data type for a given Felis column type.

Parameters:
felis_type : type

Felis type, on of the classes defined in felis.types module.

Returns:
column_dtype : type or str

Type that can be used for columns in Pandas.

Raises:
TypeError

Raised if type is cannot be handled.

getColumnMap(table_name: lsst.dax.apdb.apdbSchema.ApdbTables | lsst.dax.apdb.apdbCassandraSchema.ExtraTables[lsst.dax.apdb.apdbSchema.ApdbTables, lsst.dax.apdb.apdbCassandraSchema.ExtraTables]) → collections.abc.Mapping[str, felis.simple.Column]

Returns mapping of column names to Column definitions.

Parameters:
table_name : ApdbTables

One of known APDB table names.

Returns:
column_map : dict

Mapping of column names to ColumnDef instances.

makeSchema(drop: bool = False, part_range: Optional[Tuple[int, int], None] = None) → None

Create or re-create all tables.

Parameters:
drop : bool

If True then drop tables before creating new ones.

part_range : tuple [ int ] or None

Start and end partition number for time partitions, end is not inclusive. Used to create per-partition DiaObject, DiaSource, and DiaForcedSource tables. If None then per-partition tables are not created.

partitionColumns(table_name: lsst.dax.apdb.apdbSchema.ApdbTables | lsst.dax.apdb.apdbCassandraSchema.ExtraTables[lsst.dax.apdb.apdbSchema.ApdbTables, lsst.dax.apdb.apdbCassandraSchema.ExtraTables]) → List[str]

Return a list of columns used for table partitioning.

Parameters:
table_name : ApdbTables

Table name in APDB schema

Returns:
columns : list of str

Names of columns used for partitioning.

tableName(table_name: lsst.dax.apdb.apdbSchema.ApdbTables | lsst.dax.apdb.apdbCassandraSchema.ExtraTables[lsst.dax.apdb.apdbSchema.ApdbTables, lsst.dax.apdb.apdbCassandraSchema.ExtraTables]) → str

Return Cassandra table name for APDB table.