MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_cube_operators

Method test_cube_operators

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

Source from the content-addressed store, hash-verified

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

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