Skip to content

Commit

Permalink
documented segment_metadata. fixed a bug in it too
Browse files Browse the repository at this point in the history
  • Loading branch information
Deep Ganguli committed Mar 5, 2014
1 parent 1e050bc commit 8d570e4
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion pydruid/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,38 @@ def groupby(self, **kwargs):
return self.__post(self.query_dict)

def segment_metadata(self, **kwargs):
self.query_type = 'segmentMetaData'
"""
A segment meta-data query returns per segment information about:
* Cardinality of all the columns present
* Column type
* Estimated size in bytes
* Estimated size in bytes of each column
* Interval the segment covers
* Segment ID
Required key/value pairs:
:param str datasource: Data source to query
:param intervals: ISO-8601 intervals for which to run the query on
:type intervals: str or list
:return: The query result
:rtype: list[dict]
Example:
.. code-block:: python
:linenos:
>>> meta = query.segment_metadata(datasource='twitterstream', intervals = '2013-10-04/pt1h')
>>> print meta[0].keys()
>>> ['intervals', 'id', 'columns', 'size']
>>> print meta[0]['columns']['tweet_length']
>>> {'errorMessage': None, 'cardinality': None, 'type': 'FLOAT', 'size': 30908008}
"""
self.query_type = 'segmentMetadata'
valid_parts = ['datasource', 'intervals']
self.validate_query(valid_parts, kwargs)
self.build_query(kwargs)
Expand Down

0 comments on commit 8d570e4

Please sign in to comment.