From bdf6bac474edf233e0b2231f854e68c9e80fd7c4 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 5 Jan 2018 16:49:37 -0800 Subject: [PATCH] Add support for 'scan' queries (#108) --- pydruid/query.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pydruid/query.py b/pydruid/query.py index bfb9dd24..8ffd1fee 100644 --- a/pydruid/query.py +++ b/pydruid/query.py @@ -179,6 +179,10 @@ def export_pandas(self): nres = [] for item in self.result: nres += [e.get('event') for e in item['result'].get('events')] + elif self.query_type == "scan": + nres = [] + for item in self.result: + nres += [e for e in item.get('events')] else: raise NotImplementedError( 'Pandas export not implemented for query ' @@ -423,3 +427,20 @@ def search(self, args): ] self.validate_query(query_type, valid_parts, args) return self.build_query(query_type, args) + + def scan(self, args): + """ + A scan query returns raw Druid rows + + :param dict args: dict of args + + :return: select query + :rtype: Query + """ + query_type = 'scan' + valid_parts = [ + 'datasource', 'granularity', 'filter', 'dimensions', 'metrics', + 'intervals', 'limit', + ] + self.validate_query(query_type, valid_parts, args) + return self.build_query(query_type, args)