def test_compile_EvalSum(self): with self.assertRaises(qc.CompilationError): qe.Sum([qc.EvalConstant('testing')]) c_sum = qe.Sum([qc.EvalConstant(17)]) self.assertEqual(int, c_sum.dtype) c_sum = qe.Sum([qc.EvalConstant(D('17.'))]) self.assertEqual(Decimal, c_sum.dtype)
def test_is_aggregate_derived(self): columns, aggregates = qc.get_columns_and_aggregates( qc.EvalAnd( qc.EvalEqual(qe.PositionColumn(), qc.EvalConstant(42)), qc.EvalOr( qc.EvalNot(qc.EvalEqual(qe.DateColumn(), qc.EvalConstant(datetime.date(2014, 1, 1)))), qc.EvalConstant(False)))) self.assertEqual((2, 0), (len(columns), len(aggregates))) columns, aggregates = qc.get_columns_and_aggregates( qc.EvalAnd( qc.EvalEqual(qe.PositionColumn(), qc.EvalConstant(42)), qc.EvalOr( qc.EvalNot(qc.EvalEqual(qe.DateColumn(), qc.EvalConstant(datetime.date(2014, 1, 1)))), # Aggregation node deep in the tree. qe.Sum([qc.EvalConstant(1)])))) self.assertEqual((2, 1), (len(columns), len(aggregates)))