Skip to content

Commit

Permalink
feat: update druid query context (#304)
Browse files Browse the repository at this point in the history
- add filter pairs to query context
- add source `numalogic` to query context

---------
Signed-off-by: shrivardhan <[email protected]>
  • Loading branch information
cosmic-chichu committed Oct 2, 2023
1 parent a0e0ad0 commit d7f9605
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion numalogic/connectors/druid/_druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def build_params(
"post_aggregations": post_aggregations or dict(),
"filter": _filter,
"dimensions": dimension_specs,
"context": {"timeout": TIMEOUT},
"context": {"timeout": TIMEOUT, "configIds": list(filter_pairs), "source": "numalogic"},
}


Expand Down
14 changes: 10 additions & 4 deletions tests/connectors/test_druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,21 @@ def test_fetch_double_sketch(self):
self.assertEqual((2, 5), _out.shape)

def test_build_param(self):
filter_pairs = make_filter_pairs(["ciStatus"], ["false"])
expected = {
"datasource": "foo",
"dimensions": map(lambda d: DimensionSpec(dimension=d, output_name=d), ["bar"]),
"filter": [Filter(type="selector", dimension="ciStatus", value="false")],
"filter": Filter(
type="and",
fields=[Filter(type="selector", dimension="ciStatus", value="false")],
),
"granularity": "all",
"aggregations": "",
"aggregations": dict(),
"post_aggregations": dict(),
"intervals": "",
"context": {"timeout": 10000, "configIds": list(filter_pairs), "source": "numalogic"},
}

filter_pairs = make_filter_pairs(["ciStatus"], ["false"])
actual = build_params(
datasource="foo",
dimensions=["bar"],
Expand All @@ -141,7 +146,8 @@ def test_build_param(self):
hours=24.0,
delay=3,
)
diff = DeepDiff(expected, actual).get("values_changed", {})
actual["intervals"] = ""
diff = DeepDiff(expected, actual, ignore_order=True)
self.assertDictEqual({}, diff)

@patch.object(PyDruid, "groupby", Mock(side_effect=OSError))
Expand Down

0 comments on commit d7f9605

Please sign in to comment.