Example #1
0
    def test_variance(self):
        expr = an.Variance(self.table_abc.fizz) \
            .over(self.table_abc.foo, self.table_abc.bar) \
            .orderby(self.table_abc.date)

        q = Query.from_(self.table_abc).select(expr)

        self.assertEqual(
            'SELECT '
            'VARIANCE("fizz") '
            'OVER(PARTITION BY "foo","bar" ORDER BY "date") '
            'FROM "abc"', str(q))
Example #2
0
    def test_variance_rows_between_unbounded_preceeding_unbounded_following(
            self):
        expr = an.Variance(self.table_abc.fizz) \
            .over(self.table_abc.foo) \
            .orderby(self.table_abc.date) \
            .rows(an.Preceding(), an.Following())

        q = Query.from_(self.table_abc).select(expr)

        self.assertEqual(
            'SELECT '
            'VARIANCE("fizz") '
            'OVER('
            'PARTITION BY "foo" ORDER BY "date" '
            'ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING'
            ') '
            'FROM "abc"', str(q))