Legacy Conversion

snuba_sdk.legacy.is_condition(cond_or_list)[source]

Checks whether a legacy expression is a condition or not.

Parameters

cond_or_list (Sequence[Any]) – A sequence of legacy values.

Return type

bool

snuba_sdk.legacy.json_to_snql(body, entity)[source]

This will output a Request object that matches the Legacy query body that was passed in. The entity is necessary since the SnQL API requires an explicit entity. This doesn’t support subquery or joins.

Parameters
  • body (Mapping[str, Any]) – The legacy API body.

  • entity (str) – The name of the entity being queried.

Raises

InvalidExpressionError, InvalidQueryError, InvalidRequestError – If the legacy body is invalid, the SDK will raise an exception.

Return type

Request

snuba_sdk.legacy.parse_condition(cond)[source]

Convert a legacy condition into an SDK condition.

Parameters

cond (Sequence[Any]) – A legacy condition array.

Return type

Condition

snuba_sdk.legacy.parse_condition_to_function(cond)[source]
Return type

Function

snuba_sdk.legacy.parse_datetime(date_str)[source]

Tries to convert a string to a datetime using one of the different date formats.

Parameters

date_str (str) – A possible datetime string.

Raises

ValueError – If the string is not a valid datetime.

Return type

datetime

snuba_sdk.legacy.parse_exp(value)[source]

Takes a legacy expression and converts it to an equivalent SDK Expression.

Parameters

value (Any) – A legacy expression.

Return type

Any

snuba_sdk.legacy.parse_extension_condition(col, values, always_in=False)[source]

Create an SDK condition using the values passed as extensions in the legacy API.

Parameters
  • col (str) – The column that the automatic condition applies too.

  • values (Any) – The RHS values of the condition. Could be a single scalar or a sequence of values.

  • always_in (bool) – Some conditions always use an IN condition, even if there is a single value.

Return type

Optional[Condition]

snuba_sdk.legacy.parse_scalar(value, only_strings=False)[source]

Convert a scalar value into the expected value for the SDK.

Parameters

value (Any) – A value to be converted for the SDK.

Return type

Any

snuba_sdk.legacy.parse_string(value)[source]
Return type

str