druid-io / pydruid

A Python connector for Druid
Other
506 stars 194 forks source link

Pass context to Druid #152

Closed betodealmeida closed 5 years ago

betodealmeida commented 5 years ago

Druid accepts a context object when being queried, eg:

{
  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time > TIMESTAMP '2000-01-01 00:00:00'",
  "context" : {
        "user": "amalakar@lyft.com",
        "source": "superset",
        "user_id": "google_325325",
        "user_id_type": "google"
  }
}

I add a hook for passing a context object either in the SQL Alchemy connection or the Python DB API connection. I also added a unit test.

betodealmeida commented 5 years ago

@mistercrunch

amalakar commented 5 years ago

Thank you for this change, context also lets clients override timeout, useCache and many other important tuning parameter per query as can be seen in: http://druid.io/docs/latest/querying/query-context.html This PR would allow pydruid users to configure those per query which was not possible earlier.

mistercrunch commented 5 years ago

LGTM

mistercrunch commented 5 years ago

let me push a version out with this