def _get_having_obj(self, col, op, eq): cond = None if op == '==': if col in self.column_names: cond = DimSelector(dimension=col, value=eq) else: cond = Aggregation(col) == eq elif op == '>': cond = Aggregation(col) > eq elif op == '<': cond = Aggregation(col) < eq return cond
def test_not_having(self): h1 = Aggregation("sum") > 1 actual = Having.build_having(~h1) expected = { "type": "not", "havingSpec": { "type": "greaterThan", "aggregation": "sum", "value": 1 }, } assert actual == expected
def test_or_having(self): h1 = Aggregation("sum1") > 1 h2 = Aggregation("sum2") > 2 actual = Having.build_having(h1 | h2) expected = { "type": "or", "havingSpecs": [ { "type": "greaterThan", "aggregation": "sum1", "value": 1 }, { "type": "greaterThan", "aggregation": "sum2", "value": 2 }, ], } assert actual == expected
def test_greaterThan_having_Aggregation(self): h1 = Aggregation("sum") > 1 actual = Having.build_having(h1) expected = {"type": "greaterThan", "aggregation": "sum", "value": 1} assert actual == expected
def test_equalTo_having_Aggregation(self): h1 = Aggregation("sum") == 1 actual = Having.build_having(h1) expected = {"type": "equalTo", "aggregation": "sum", "value": 1} assert actual == expected