Exemplo n.º 1
0
def test_query_extension_processing(
    raw_data: dict,
    expected_conditions: Sequence[Condition],
    expected_granularity: int,
):
    state.set_config('max_days', 1)
    extension = TimeSeriesExtension(
        default_granularity=60,
        default_window=datetime.timedelta(days=5),
        timestamp_column='timestamp',
    )
    valid_data = validate_jsonschema(raw_data, extension.get_schema())
    query = Query(
        {"conditions": []},
        TableSource("my_table", ColumnSet([])),
    )

    request_settings = RequestSettings(turbo=False,
                                       consistent=False,
                                       debug=False)

    extension.get_processor().process_query(query, valid_data,
                                            request_settings)
    assert query.get_conditions() == expected_conditions
    assert query.get_granularity() == expected_granularity
Exemplo n.º 2
0
def test_query_extension_processing(raw_data: dict,
                                    expected_conditions: Sequence[Condition]):
    state.set_config('max_days', 1)
    extension = TimeSeriesExtension(
        default_granularity=3600,
        default_window=datetime.timedelta(days=5),
        timestamp_column='timestamp',
    )
    valid_data = validate_jsonschema(raw_data, extension.get_schema())
    query = Query({"conditions": []})

    extension.get_processor().process_query(query, valid_data)
    assert query.get_conditions() == expected_conditions
Exemplo n.º 3
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         "timeseries": TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=7),
             timestamp_column="timestamp",
         ),
         "organization": OrganizationExtension(),
     }
Exemplo n.º 4
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         'performance': PerformanceExtension(),
         'project': ProjectExtension(),
         'timeseries': TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column='timestamp',
         ),
     }
Exemplo n.º 5
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         "project": ProjectExtension(
             processor=ProjectExtensionProcessor(project_column="project_id")
         ),
         "timeseries": TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column="start_ts",
         ),
     }
Exemplo n.º 6
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         'project':
         ProjectExtension(processor=ProjectExtensionProcessor()),
         'timeseries':
         TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column='start_ts',
         ),
     }
Exemplo n.º 7
0
def test_query_extension_processing(
    raw_data: dict,
    expected_conditions: Sequence[Condition],
    expected_ast_condition: Expression,
    expected_granularity: int,
):
    state.set_config("max_days", 1)
    extension = TimeSeriesExtension(
        default_granularity=60,
        default_window=timedelta(days=5),
        timestamp_column="timestamp",
    )
    valid_data = validate_jsonschema(raw_data, extension.get_schema())
    query = Query({"conditions": []}, TableSource("my_table", ColumnSet([])),)

    request_settings = HTTPRequestSettings()

    extension.get_processor().process_query(query, valid_data, request_settings)
    assert query.get_conditions() == expected_conditions
    assert query.get_condition_from_ast() == expected_ast_condition
    assert query.get_granularity() == expected_granularity
Exemplo n.º 8
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         'project':
         ProjectExtension(processor=ProjectWithGroupsProcessor(
             project_column="events.project_id")),
         'timeseries':
         TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column='events.timestamp',
         ),
     }
Exemplo n.º 9
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         "project": ProjectExtension(
             processor=ProjectWithGroupsProcessor(
                 project_column="events.project_id", replacer_state_name=None,
             )
         ),
         "timeseries": TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column="events.timestamp",
         ),
     }