Skip to content

Commit

Permalink
feat: use well-defined dimensions instead of strings (#284)
Browse files Browse the repository at this point in the history
Using dimensions as a list of strings causes ambiguity in other druid
clients. Well-defined dimensions makes use of the utility in pydruid to
create dimensions as DimensionSpec. This helps with deterministic
serialization and de-serialization of the query.

---------

Signed-off-by: shrivardhan <[email protected]>
Co-authored-by: Avik Basu <[email protected]>
  • Loading branch information
cosmic-chichu and ab93 authored Sep 13, 2023
1 parent de8930a commit 0cdc257
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion numalogic/connectors/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pandas as pd
import pytz
from pydruid.client import PyDruid
from pydruid.utils.dimensions import DimensionSpec
from pydruid.utils.filters import Filter
from numalogic.connectors._config import Pivot
from typing import Optional
Expand Down Expand Up @@ -50,13 +51,15 @@ def fetch_data(
start_dt = end_dt - timedelta(hours=hours)
intervals = f"{start_dt.isoformat()}/{end_dt.isoformat()}"

dimension_specs = map(lambda d: DimensionSpec(dimension=d, output_name=d), dimensions)

params = {
"datasource": datasource,
"granularity": granularity,
"intervals": intervals,
"aggregations": aggregations,
"filter": _filter,
"dimensions": dimensions,
"dimensions": dimension_specs,
}

_LOGGER.debug(
Expand Down

0 comments on commit 0cdc257

Please sign in to comment.