Ejemplo n.º 1
0
    def test_ntile_with_order(self):
        expr = an.NTile(5).orderby(self.table_abc.date)

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

        self.assertEqual(
            "SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)
        )
Ejemplo n.º 2
0
    def test_ntile_with_partition(self):
        expr = an.NTile(5).over(self.table_abc.foo)

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

        self.assertEqual(
            "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)
        )
Ejemplo n.º 3
0
    def test_ntile_with_partition_and_order(self):
        expr = an.NTile(5) \
            .over(self.table_abc.foo) \
            .orderby(self.table_abc.date)

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

        self.assertEqual(
            'SELECT '
            'NTILE(5) '
            'OVER(PARTITION BY "foo" ORDER BY "date") '
            'FROM "abc"', str(q))
Ejemplo n.º 4
0
    def test_ntile_no_partition_or_order_invalid_sql(self):
        expr = an.NTile(5)

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

        self.assertEqual('SELECT ' 'NTILE(5) ' 'FROM "abc"', str(q))