Expressions

class snuba_sdk.column.Column(name, entity=None)[source]

Bases: snuba_sdk.expressions.Expression

A representation of a single column in the database. Columns are expected to be alpha-numeric, with ‘.’, ‘, and `: allowed as well. If the column is subscriptable then you can specify the column in the form subscriptable[key]. The subscriptable attribute will contain the outer column and key will contain the inner key.

Parameters
  • name (Optional[Entity]) – The column name.

  • entity (Optional[Entity]) – The entity for that column

Raises

InvalidColumnError – If the column name is not a string or has an invalid format.

entity: Optional[snuba_sdk.entity.Entity] = None
key: Optional[str] = None
name: str
subscriptable: Optional[str] = None
validate()[source]
Return type

None

validate_data_model(entity)[source]
Return type

None

exception snuba_sdk.column.InvalidColumnError[source]

Bases: snuba_sdk.expressions.InvalidExpressionError

class snuba_sdk.function.CurriedFunction(function, initializers=None, parameters=None, alias=None)[source]

Bases: snuba_sdk.expressions.Expression

alias: Optional[str] = None
function: str
initializers: Optional[Sequence[Union[None, bool, str, bytes, float, int, datetime.date, datetime.datetime, snuba_sdk.column.Column]]] = None
parameters: Optional[Sequence[Union[None, bool, str, bytes, float, int, datetime.date, datetime.datetime, Sequence[Union[snuba_sdk.expressions.Expression, None, bool, str, bytes, float, int, datetime.date, datetime.datetime]], snuba_sdk.column.Column, snuba_sdk.function.CurriedFunction, snuba_sdk.function.Function, snuba_sdk.function.Identifier, snuba_sdk.function.Lambda]]] = None
validate()[source]
Return type

None

class snuba_sdk.function.Function(function, parameters=None, alias=None)[source]

Bases: snuba_sdk.function.CurriedFunction

initializers: Optional[Sequence[Union[None, bool, str, bytes, float, int, datetime.date, datetime.datetime, snuba_sdk.column.Column]]] = None
class snuba_sdk.function.Identifier(name)[source]

Bases: snuba_sdk.expressions.Expression

name: str
validate()[source]
Return type

None

exception snuba_sdk.function.InvalidFunctionError[source]

Bases: snuba_sdk.expressions.InvalidExpressionError

exception snuba_sdk.function.InvalidLambdaError[source]

Bases: snuba_sdk.expressions.InvalidExpressionError

class snuba_sdk.function.Lambda(identifiers, transformation)[source]

Bases: snuba_sdk.expressions.Expression

identifiers: Sequence[str]
transformation: snuba_sdk.function.CurriedFunction
validate()[source]
Return type

None

class snuba_sdk.orderby.Direction(value)[source]

Bases: enum.Enum

An enumeration.

ASC = 'ASC'
DESC = 'DESC'
class snuba_sdk.orderby.LimitBy(columns, count)[source]

Bases: snuba_sdk.expressions.Expression

columns: Sequence[snuba_sdk.column.Column]
count: int
validate()[source]
Return type

None

class snuba_sdk.orderby.OrderBy(exp, direction)[source]

Bases: snuba_sdk.expressions.Expression

direction: snuba_sdk.orderby.Direction
exp: Union[snuba_sdk.column.Column, snuba_sdk.function.CurriedFunction, snuba_sdk.function.Function]
validate()[source]
Return type

None

snuba_sdk.orderby.validate_sequence_of_type(name, val, type, minimum_length)[source]
Return type

None

class snuba_sdk.expressions.Expression[source]

Bases: abc.ABC

abstract validate()[source]
Return type

None

class snuba_sdk.expressions.Granularity(granularity)[source]

Bases: snuba_sdk.expressions.Expression

granularity: int
validate()[source]
Return type

None

exception snuba_sdk.expressions.InvalidArrayError(value)[source]

Bases: Exception

exception snuba_sdk.expressions.InvalidExpressionError[source]

Bases: Exception

class snuba_sdk.expressions.Limit(limit)[source]

Bases: snuba_sdk.expressions.Expression

limit: int
validate()[source]
Return type

None

class snuba_sdk.expressions.Offset(offset)[source]

Bases: snuba_sdk.expressions.Expression

offset: int
validate()[source]
Return type

None

class snuba_sdk.expressions.Totals(totals)[source]

Bases: snuba_sdk.expressions.Expression

totals: bool
validate()[source]
Return type

None

snuba_sdk.expressions.is_literal(value)[source]

Allow simple scalar types but not lists/tuples.

Return type

bool

snuba_sdk.expressions.is_scalar(value)[source]
Return type

bool