Beispiel #1
0
def nested_expression(column: str, key: str) -> FunctionCall:
    return build_mapping_expr(
        alias=f"{column}[{key}]",
        table_name=None,
        col_name=column,
        mapping_key=Literal(None, key),
    )
Beispiel #2
0
 from_clause=events_table,
 selected_columns=[
     SelectedExpression("project_id",
                        Column(None, None, "project_id")),
     SelectedExpression(
         "count_environment",
         FunctionCall(
             "count_environment",
             function_name="ifNull",
             parameters=(
                 FunctionCall(
                     None,
                     "uniq",
                     (build_mapping_expr(
                         None,
                         None,
                         "tags",
                         Literal(None, "environment"),
                     ), ),
                 ),
                 Literal(alias=None, value=0),
             ),
         ),
     ),
 ],
 groupby=[Column(None, None, "project_id")],
 condition=binary_condition(
     BooleanFunctions.AND,
     binary_condition(
         ConditionFunctions.EQ,
         Column(None, None, "project_id"),
         Literal(None, 1),
             ),
             binary_condition(
                 None,
                 BooleanFunctions.AND,
                 binary_condition(
                     None,
                     ConditionFunctions.LT,
                     Column(None, None, "timestamp"),
                     Literal(None, datetime(2020, 9, 1)),
                 ),
                 binary_condition(
                     None,
                     ConditionFunctions.EQ,
                     build_mapping_expr(
                         "tags[asd]",
                         None,
                         "tags",
                         Literal(None, "asd"),
                     ),
                     Literal(None, "sdf"),
                 ),
             ),
         ),
         groupby=[
             Column("column2", None, "column2"),
             Column("column3", None, "column3"),
         ],
     )),
 ClickhouseQueryProfile(
     time_range=31,
     table="events",
     all_columns={