(self)
| 311 | ) |
| 312 | |
| 313 | def test_cube_operators(self): |
| 314 | t = table( |
| 315 | "t", |
| 316 | column("value"), |
| 317 | column("x"), |
| 318 | column("y"), |
| 319 | column("z"), |
| 320 | column("q"), |
| 321 | ) |
| 322 | |
| 323 | stmt = select(func.sum(t.c.value)) |
| 324 | |
| 325 | self.assert_compile( |
| 326 | stmt.group_by(func.cube(t.c.x, t.c.y)), |
| 327 | "SELECT sum(t.value) AS sum_1 FROM t GROUP BY CUBE(t.x, t.y)", |
| 328 | ) |
| 329 | |
| 330 | self.assert_compile( |
| 331 | stmt.group_by(func.rollup(t.c.x, t.c.y)), |
| 332 | "SELECT sum(t.value) AS sum_1 FROM t GROUP BY ROLLUP(t.x, t.y)", |
| 333 | ) |
| 334 | |
| 335 | self.assert_compile( |
| 336 | stmt.group_by(func.grouping_sets(t.c.x, t.c.y)), |
| 337 | "SELECT sum(t.value) AS sum_1 FROM t " |
| 338 | "GROUP BY GROUPING SETS(t.x, t.y)", |
| 339 | ) |
| 340 | |
| 341 | self.assert_compile( |
| 342 | stmt.group_by( |
| 343 | func.grouping_sets( |
| 344 | sql.tuple_(t.c.x, t.c.y), sql.tuple_(t.c.z, t.c.q) |
| 345 | ) |
| 346 | ), |
| 347 | "SELECT sum(t.value) AS sum_1 FROM t GROUP BY " |
| 348 | "GROUPING SETS((t.x, t.y), (t.z, t.q))", |
| 349 | ) |
| 350 | |
| 351 | def test_generic_annotation(self): |
| 352 | fn = func.coalesce("x", "y")._annotate({"foo": "bar"}) |
nothing calls this directly
no test coverage detected