Example #1
0
def test_col_split_conditions(
    id_column: str, project_column: str, timestamp_column: str, query, expected_result
) -> None:
    dataset = get_dataset("events")
    query = parse_query(query, dataset)
    splitter = ColumnSplitQueryStrategy(id_column, project_column, timestamp_column)
    request = Request("a", query, HTTPRequestSettings(), {}, "r")
    entity = get_entity(query.get_from_clause().key)
    plan = entity.get_query_plan_builder().build_plan(request)

    def do_query(
        query: ClickhouseQuery, request_settings: RequestSettings,
    ) -> QueryResult:
        return QueryResult(
            {
                "data": [
                    {
                        id_column: "asd123",
                        project_column: 123,
                        timestamp_column: "2019-10-01 22:33:42",
                    }
                ]
            },
            {},
        )

    assert (
        splitter.execute(plan.query, HTTPRequestSettings(), do_query) is not None
    ) == expected_result
Example #2
0
def test_col_split_conditions(id_column: str, project_column: str,
                              timestamp_column: str, query,
                              expected_result) -> None:
    dataset = get_dataset("events")
    query = parse_query(query, dataset)
    splitter = ColumnSplitQueryStrategy(id_column, project_column,
                                        timestamp_column)

    def do_query(query: ClickhouseQuery,
                 request_settings: RequestSettings = None) -> QueryResult:
        return QueryResult(
            {
                "data": [{
                    id_column: "asd123",
                    project_column: 123,
                    timestamp_column: "2019-10-01 22:33:42",
                }]
            },
            {},
        )

    assert (splitter.execute(query, HTTPRequestSettings(), do_query)
            is not None) == expected_result