sqlalchemy_singlestoredb.ColumnGroup

class sqlalchemy_singlestoredb.ColumnGroup(*, name: str | None = None)

SingleStore COLUMN GROUP DDL element.

Represents a COLUMN GROUP constraint that creates a materialized copy of each row as a separate index for columnstore tables, improving full-row retrieval/update on wide tables.

Parameters:

name (str, optional, keyword-only) – Optional name for the column group. If not provided, SingleStore will auto-generate a name. Must be passed as a keyword argument if specified.

Examples

Column group with name:

>>> ColumnGroup(name='cg_all_columns')

Column group without explicit name (auto-generated):

>>> ColumnGroup()

Table Usage:

from sqlalchemy import Column, Integer, MetaData, String, Table
from sqlalchemy_singlestoredb import ColumnGroup, ColumnStore
metadata = MetaData()
wide_table = Table(
    'wide_table', metadata,
    Column('id', Integer, primary_key=True),
    Column('col1', String(100)),
    Column('col2', String(100)),
    singlestoredb_table_type=ColumnStore(),
    singlestoredb_column_group=ColumnGroup(name='cg_all'),
)
# Column group with auto-generated name
analytics = Table(
    'analytics', metadata,
    Column('id', Integer, primary_key=True),
    Column('data', String(255)),
    singlestoredb_table_type=ColumnStore(),
    singlestoredb_column_group=ColumnGroup(),
)

ORM Usage:

from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import declarative_base
from sqlalchemy_singlestoredb import ColumnGroup, ColumnStore
Base = declarative_base()
class WideTable(Base):
    __tablename__ = 'wide_table'
    id = Column(Integer, primary_key=True)
    col1 = Column(String(100))
    col2 = Column(String(100))
    __table_args__ = {
        'singlestoredb_table_type': ColumnStore(),
        'singlestoredb_column_group': ColumnGroup(name='cg_all'),
    }
class Analytics(Base):
    __tablename__ = 'analytics'
    id = Column(Integer, primary_key=True)
    data = Column(String(255))
    __table_args__ = {
        'singlestoredb_table_type': ColumnStore(),
        'singlestoredb_column_group': ColumnGroup(),
    }

Notes

  • Only supported on columnstore tables

  • Automatically applies to all columns (uses * syntax)

  • Subset column groups are not supported by SingleStore

  • Improves full-row retrieval/update performance on wide tables

  • Uses less RAM than rowstore for similar use cases

  • If name is not provided, SingleStore will auto-generate one

__init__(*, name: str | None = None) None

Methods

__init__(*[, name])

against(target)

Return a copy of this _schema.ExecutableDDLElement which will include the given target.

compare(other, **kw)

Compare this _expression.ClauseElement to the given _expression.ClauseElement.

compile([bind, dialect])

Compile this SQL expression.

execute_if([dialect, callable_, state])

Return a callable that will execute this _ddl.ExecutableDDLElement conditionally within an event handler.

execution_options(**kw)

Set non-SQL options for the statement which take effect during execution.

get_children(*[, omit_attrs])

Return immediate child visitors.HasTraverseInternals elements of this visitors.HasTraverseInternals.

get_execution_options()

Get the non-SQL options which will take effect during execution.

memoized_instancemethod(fn)

Decorate a method memoize its return value.

options(*options)

Apply options to this statement.

params([_ClauseElement__optionaldict])

Return a copy with _expression.bindparam() elements replaced.

self_group([against])

Apply a 'grouping' to this _expression.ClauseElement.

unique_params([_ClauseElement__optionaldict])

Return a copy with _expression.bindparam() elements replaced.

Attributes

allows_lambda

description

entity_namespace

inherit_cache

Indicate if this HasCacheKey instance should make use of the cache key generation scheme used by its immediate superclass.

is_clause_element

is_delete

is_dml

is_from_statement

is_insert

is_select

is_selectable

is_text

is_update

stringify_dialect

supports_execution

target

uses_inspection

name

negation_clause

proxy_set