Skip to content

Column

scylla_bridge.column.Column

Represents a column in a ScyllaDB query.

Parameters:

Name Type Description Default
_expr Optional[ColumnExpr]

The column expression associated with the column, by default None.

required
_table Optional[str]

The name of the table, by default None.

required
_keyspace Optional[str]

The name of the keyspace, by default None.

required
_name Optional[str]

The name of the column, by default None.

required
rename Optional[str]

An alias for the column, by default None.

required

rename class-attribute instance-attribute

rename = None

type instance-attribute

type

in_

in_(value)

Creates a column expression for an "IN" comparison.

Parameters:

Name Type Description Default
value Iterable

An iterable containing the values to compare against the column.

required

Returns:

Type Description
ColumnExpr

The column expression representing the "IN" comparison.

Source code in scylla_bridge/column.py
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
@validate_call
def in_(self, value: Iterable) -> ColumnExpr:
    """Creates a column expression for an "IN" comparison.

    Parameters
    ----------
    value : Iterable
        An iterable containing the values to compare against the column.

    Returns
    -------
    ColumnExpr
        The column expression representing the "IN" comparison.
    """
    assert (
        self._name is not None
        and self._table is not None
        and self._keyspace is not None
    ), "Column name is not set!"
    return ColumnExpr(self._table, self._name, self._keyspace, " IN ", value)

label

label(name)

Assigns an alias to the column.

Parameters:

Name Type Description Default
name str

The new alias for the column.

required

Returns:

Type Description
Column

The updated column with the new alias.

Source code in scylla_bridge/column.py
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
@validate_call
def label(self, name: str) -> Column:
    """Assigns an alias to the column.

    Parameters
    ----------
    name : str
        The new alias for the column.

    Returns
    -------
    Column
        The updated column with the new alias.
    """
    self.rename = name
    return self

mean

mean()

Creates an aggregate expression for the AVG (mean) function.

Returns:

Type Description
AggregateExpr

The aggregate expression representing the AVG function.

Source code in scylla_bridge/column.py
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
def mean(self) -> AggregateExpr:
    """Creates an aggregate expression for the AVG (mean) function.

    Returns
    -------
    AggregateExpr
        The aggregate expression representing the AVG function.
    """
    assert (
        self._name is not None
        and self._table is not None
        and self._keyspace is not None
    ), "Column name is not set!"
    return AggregateExpr(
        self._table, self._name, self._keyspace, "AVG", self.rename
    )

set_attributes

set_attributes(settings)

Sets multiple attributes of the column.

Parameters:

Name Type Description Default
settings dict

A dictionary where the keys are attribute names and the values are the values to set.

required

Returns:

Type Description
Column

The updated column with new attributes.

Source code in scylla_bridge/column.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def set_attributes(self, settings: dict) -> Column:
    """Sets multiple attributes of the column.

    Parameters
    ----------
    settings : dict
        A dictionary where the keys are attribute names and the values are the values to set.

    Returns
    -------
    Column
        The updated column with new attributes.
    """
    for key, value in settings.items():
        setattr(self, key, value)
    return self

sum

sum()

Creates an aggregate expression for the SUM function.

Returns:

Type Description
AggregateExpr

The aggregate expression representing the SUM function.

Source code in scylla_bridge/column.py
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
def sum(self) -> AggregateExpr:
    """Creates an aggregate expression for the SUM function.

    Returns
    -------
    AggregateExpr
        The aggregate expression representing the SUM function.
    """
    assert (
        self._name is not None
        and self._table is not None
        and self._keyspace is not None
    ), "Column name is not set!"
    return AggregateExpr(
        self._table, self._name, self._keyspace, "SUM", self.rename
    )

Column Expressions

ColumnExpr

scylla_bridge.column.ColumnExpr

Represents a column expression in a ScyllaDB query.

Parameters:

Name Type Description Default
_table str

The name of the table.

required
_name str

The name of the column.

required
_keyspace str

The name of the keyspace.

required
operator str

The comparison operator used in the expression (e.g., '=', '<', '>', etc.).

required
value Any

The value against which the column is being compared.

required

operator instance-attribute

operator

value instance-attribute

value

AggregateExpr

scylla_bridge.column.AggregateExpr

Represents an aggregate column expression in a ScyllaDB query.

Parameters:

Name Type Description Default
_table str

The name of the table.

required
_name str

The name of the column.

required
_keyspace str

The name of the keyspace.

required
operator str

The aggregate function applied to the column (e.g., 'SUM', 'AVG').

required
rename Optional[str]

An alias for the column, by default None.

required

operator instance-attribute

operator

rename class-attribute instance-attribute

rename = None

label

label(name)

Assigns an alias to the aggregate expression.

Parameters:

Name Type Description Default
name str

The new alias for the column.

required

Returns:

Type Description
AggregateExpr

The updated aggregate expression with the new alias.

Source code in scylla_bridge/column.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@validate_call
def label(self, name: str) -> AggregateExpr:
    """Assigns an alias to the aggregate expression.

    Parameters
    ----------
    name : str
        The new alias for the column.

    Returns
    -------
    AggregateExpr
        The updated aggregate expression with the new alias.
    """
    self.rename = name
    return self