Query

class snuba_sdk.query.Query(match, select=None, groupby=None, array_join=None, where=None, having=None, orderby=None, limitby=None, limit=None, offset=None, granularity=None, totals=None)[source]

Bases: object

A code representation of a SnQL query. It is immutable, so any set functions return a new copy of the query. Unlike Expressions it is possible to instantiate a Query that is invalid. Any of the translation functions will validate the query before translating them, so the query must be valid before they are called.

array_join: Optional[Sequence[snuba_sdk.column.Column]] = None
get_fields()[source]
Return type

Sequence[str]

granularity: Optional[snuba_sdk.expressions.Granularity] = None
groupby: Optional[Sequence[Union[snuba_sdk.aliased_expression.AliasedExpression, snuba_sdk.column.Column, snuba_sdk.function.CurriedFunction, snuba_sdk.function.Function]]] = None
having: Optional[Sequence[Union[snuba_sdk.conditions.BooleanCondition, snuba_sdk.conditions.Condition]]] = None
limit: Optional[snuba_sdk.expressions.Limit] = None
limitby: Optional[snuba_sdk.orderby.LimitBy] = None
match: Union[snuba_sdk.entity.Entity, snuba_sdk.relationships.Join, snuba_sdk.query.Query]
offset: Optional[snuba_sdk.expressions.Offset] = None
orderby: Optional[Sequence[snuba_sdk.orderby.OrderBy]] = None
print()[source]
Return type

str

select: Optional[Sequence[Union[snuba_sdk.aliased_expression.AliasedExpression, snuba_sdk.column.Column, snuba_sdk.function.CurriedFunction, snuba_sdk.function.Function]]] = None
serialize()[source]
Return type

str

set_array_join(array_join)[source]
Return type

Query

set_granularity(granularity)[source]
Return type

Query

set_groupby(groupby)[source]
Return type

Query

set_having(conditions)[source]
Return type

Query

set_limit(limit)[source]
Return type

Query

set_limitby(limitby)[source]
Return type

Query

set_match(match)[source]
Return type

Query

set_offset(offset)[source]
Return type

Query

set_orderby(orderby)[source]
Return type

Query

set_select(select)[source]
Return type

Query

set_totals(totals)[source]
Return type

Query

set_where(conditions)[source]
Return type

Query

totals: Optional[snuba_sdk.expressions.Totals] = None
validate()[source]
Return type

None

where: Optional[Sequence[Union[snuba_sdk.conditions.BooleanCondition, snuba_sdk.conditions.Condition]]] = None
snuba_sdk.query.list_type(vals, type_classes)[source]
Return type

bool