druid-io / pydruid

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

Bound filter property is required #225

Open armanaxh opened 4 years ago

armanaxh commented 4 years ago

It is not required to fill all property in the druid bound filter. However, if we want to use ‌the Filter base class, we have this problem. We do not have this problem when using the ‌Band filter class.

https://druid.apache.org/docs/latest/querying/filters.html#bound-filter

client.groupby(
    datasource='cafebazaar.tmp_datasource',
    granularity=granularity,
    intervals=date_range,
    aggregations={'count': longsum('count')},
    filter=Filter(type='bound', dimension='count', lower='1', upper='10'),
    ).result
pydruid/pydruid/utils/filters.py in __init__(self, extraction_function, ordering, **args)
     81                     "dimension": args["dimension"],
     82                     "lower": args["lower"],
---> 83                     "lowerStrict": args["lowerStrict"],
     84                     "upper": args["upper"],
     85                     "upperStrict": args["upperStrict"],
KeyError: 'lowerStrict'

After reading the code, I realized that I should use the ‌Band class directly and not the Filter base class, but if we want to use the filter class directly, we will have the problem that all the property is required(Like me). ‌

@MSadeghzadehG @john-bodley What is your opinion about the solution to this? Limit the usage of Filter class and force using the child classes? Or fix the Filter class and write a test for it?