druid-io / pydruid

A Python connector for Druid
Other
507 stars 198 forks source link

fix filter composition #43

Closed autre closed 8 years ago

autre commented 8 years ago

This should close #42.

mcorbe commented 8 years ago

Quick observation, this fix wont work if you nest "or" and "and" (basically would only return last bitwise operator).

You need to check for the actual type as such :

`` def and(self, x):

   if 'type' in self.filter['filter'] and self.filter['filter']['type'] == "and":
        flattened = self.flatten()
        flattened.extend(x.flatten())

        return Filter(type="and", fields=flattened)

    return Filter(type="and",
                  fields=[self.filter['filter'], x.filter['filter']])

``

xvrl commented 8 years ago

this seems to be similar to #46. @autre can you work with @dakra to merge your two code bases and or decide which one to use?

autre commented 8 years ago

@xvrl: from a quick look, seems like @dakra's pr is pretty similar (and maybe simpler/cleaner). Moreover it handles the case for more than one and/or's at filter construction time. If you think #46 is good to land, I'm ok with closing this one.

xvrl commented 8 years ago

@autre #46 was merged, so feel free to close this one.