MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_cube_operators

Method test_cube_operators

test/sql/test_functions.py:256–292  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

254 self.assert_compile(stmt, expected_sql, dialect=dialect)
255
256 def test_cube_operators(self):
257 t = table(
258 "t",
259 column("value"),
260 column("x"),
261 column("y"),
262 column("z"),
263 column("q"),
264 )
265
266 stmt = select(func.sum(t.c.value))
267
268 self.assert_compile(
269 stmt.group_by(func.cube(t.c.x, t.c.y)),
270 "SELECT sum(t.value) AS sum_1 FROM t GROUP BY CUBE(t.x, t.y)",
271 )
272
273 self.assert_compile(
274 stmt.group_by(func.rollup(t.c.x, t.c.y)),
275 "SELECT sum(t.value) AS sum_1 FROM t GROUP BY ROLLUP(t.x, t.y)",
276 )
277
278 self.assert_compile(
279 stmt.group_by(func.grouping_sets(t.c.x, t.c.y)),
280 "SELECT sum(t.value) AS sum_1 FROM t "
281 "GROUP BY GROUPING SETS(t.x, t.y)",
282 )
283
284 self.assert_compile(
285 stmt.group_by(
286 func.grouping_sets(
287 sql.tuple_(t.c.x, t.c.y), sql.tuple_(t.c.z, t.c.q)
288 )
289 ),
290 "SELECT sum(t.value) AS sum_1 FROM t GROUP BY "
291 "GROUPING SETS((t.x, t.y), (t.z, t.q))",
292 )
293
294 def test_generic_annotation(self):
295 fn = func.coalesce("x", "y")._annotate({"foo": "bar"})

Callers

nothing calls this directly

Calls 9

tableFunction · 0.90
columnFunction · 0.90
selectFunction · 0.90
assert_compileMethod · 0.80
cubeMethod · 0.80
rollupMethod · 0.80
grouping_setsMethod · 0.80
sumMethod · 0.45
group_byMethod · 0.45

Tested by

no test coverage detected