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) )
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) )
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))
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))