Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
('e1', 'e3'): 3,
}
self.tm1.cubes.cells.write_values(CUBE_RPS1_NAME, cells)
self.tm1.cubes.cells.relative_proportional_spread(
value=12,
cube=CUBE_RPS1_NAME,
unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[" + DIMENSION_RPS1_NAME + "].[e2]",
"[" + DIMENSION_RPS2_NAME + "].[" + DIMENSION_RPS2_NAME + "].[c1]"),
reference_cube=CUBE_RPS1_NAME,
reference_unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[" + DIMENSION_RPS1_NAME + "].[c1]",
"[" + DIMENSION_RPS2_NAME + "].[" + DIMENSION_RPS2_NAME + "].[c1]"))
mdx = MdxBuilder.from_cube(CUBE_RPS1_NAME) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_RPS1_NAME, "e2"))) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_RPS2_NAME, "e1"),
Member.of(DIMENSION_RPS2_NAME, "e2"),
Member.of(DIMENSION_RPS2_NAME, "e3")])).to_mdx()
values = self.tm1.cubes.cells.execute_mdx_values(mdx)
self.assertEqual(next(values), 2)
self.assertEqual(next(values), 4)
self.assertEqual(next(values), 6)
def test_execute_view_rows_and_values_two_dimensions_on_rows(self):
view_name = PREFIX + "MDX_View_With_Two_Dim_On_Rows"
if not self.tm1.cubes.views.exists(cube_name=CUBE_NAME, view_name=view_name, private=False):
mdx = MdxBuilder.from_cube(CUBE_NAME).add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[0], "Element1"),
Member.of(DIMENSION_NAMES[0], "Element2")])) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[1], "Element1"),
Member.of(DIMENSION_NAMES[1], "Element2")])) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[2], "Element1"),
Member.of(DIMENSION_NAMES[2], "Element2"),
Member.of(DIMENSION_NAMES[2], "Element3")])) \
.where(Member.of(DIMENSION_NAMES[2], "Element1")) \
.to_mdx()
view = MDXView(cube_name=CUBE_NAME, view_name=view_name, MDX=mdx)
self.tm1.cubes.views.create(view, False)
data = self.tm1.cubes.cells.execute_view_rows_and_values(
cube_name=CUBE_NAME,
view_name=view_name,
private=False)
self.assertEqual(len(data), 4)
for row, cells in data.items():
def test_execute_view_rows_and_values_with_member_names(self):
view_name = PREFIX + "MDX_View_With_Member_Names"
if not self.tm1.cubes.views.exists(cube_name=CUBE_NAME, view_name=view_name, private=False):
mdx = MdxBuilder.from_cube(CUBE_NAME).add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[0], "Element1"),
Member.of(DIMENSION_NAMES[0], "Element2")])) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[2], "Element1"),
Member.of(DIMENSION_NAMES[2], "Element2")])) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[1], "Element1"),
Member.of(DIMENSION_NAMES[1], "Element2"),
Member.of(DIMENSION_NAMES[1], "Element3")])) \
.where(Member.of(DIMENSION_NAMES[2], "Element1")) \
.to_mdx()
view = MDXView(cube_name=CUBE_NAME, view_name=view_name, MDX=mdx)
self.tm1.cubes.views.create(view, False)
data = self.tm1.cubes.cells.execute_view_rows_and_values(
cube_name=CUBE_NAME,
view_name=view_name,
private=False,
('e1', 'e1'): 1,
('e1', 'e2'): 2,
('e1', 'e3'): 3,
}
self.tm1.cubes.cells.write_values(CUBE_RPS1_NAME, cells)
self.tm1.cubes.cells.relative_proportional_spread(
value=12,
cube=CUBE_RPS1_NAME,
unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[e2]", "[" + DIMENSION_RPS2_NAME + "].[c1]"),
reference_cube=CUBE_RPS1_NAME,
reference_unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[c1]", "[" + DIMENSION_RPS2_NAME + "].[c1]"))
mdx = MdxBuilder.from_cube(CUBE_RPS1_NAME) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_RPS1_NAME, "e2"))) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_RPS2_NAME, "e1"),
Member.of(DIMENSION_RPS2_NAME, "e2"),
Member.of(DIMENSION_RPS2_NAME, "e3")])).to_mdx()
values = self.tm1.cubes.cells.execute_mdx_values(mdx)
self.assertEqual(next(values), 2)
self.assertEqual(next(values), 4)
self.assertEqual(next(values), 6)
def test_execute_view_rows_and_values_one_dimension_on_rows(self):
view_name = PREFIX + "MDX_View_With_One_Dim_On_Rows"
if not self.tm1.cubes.views.exists(cube_name=CUBE_NAME, view_name=view_name, private=False):
mdx = MdxBuilder.from_cube(CUBE_NAME).add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[0], "Element1"),
Member.of(DIMENSION_NAMES[0], "Element2")])) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[1], "Element1"),
Member.of(DIMENSION_NAMES[1], "Element2"),
Member.of(DIMENSION_NAMES[1], "Element3")])) \
.where(Member.of(DIMENSION_NAMES[2], "Element1")) \
.to_mdx()
view = MDXView(cube_name=CUBE_NAME, view_name=view_name, MDX=mdx)
self.tm1.cubes.views.create(view, False)
data = self.tm1.cubes.cells.execute_view_rows_and_values(
cube_name=CUBE_NAME,
view_name=view_name,
private=False)
def test_execute_mdx_rows_and_values_one_dimension_on_rows(self):
mdx = MdxBuilder.from_cube(CUBE_NAME) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[0], "Element1"),
Member.of(DIMENSION_NAMES[0], "Element2")])) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[1], "Element1"),
Member.of(DIMENSION_NAMES[1], "Element2"),
Member.of(DIMENSION_NAMES[1], "Element3")])) \
.where("[" + DIMENSION_NAMES[2] + "].[Element1]").to_mdx()
data = self.tm1.cubes.cells.execute_mdx_rows_and_values(mdx)
self.assertEqual(len(data), 2)
for row, cells in data.items():
dimension = Utils.dimension_name_from_element_unique_name(row[0])
self.assertEqual(dimension, DIMENSION_NAMES[0])
self.assertEqual(len(cells), 3)
cells = {
('e1', 'e1'): 1,
('e1', 'e2'): 2,
('e1', 'e3'): 3,
}
self.tm1.cubes.cells.write_values(CUBE_RPS1_NAME, cells)
self.tm1.cubes.cells.relative_proportional_spread(
value=12,
cube=CUBE_RPS1_NAME,
unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[e2]", "[" + DIMENSION_RPS2_NAME + "].[c1]"),
reference_unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[c1]", "[" + DIMENSION_RPS2_NAME + "].[c1]"))
mdx = MdxBuilder.from_cube(CUBE_RPS1_NAME) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_RPS1_NAME, "e2"))) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_RPS2_NAME, "e1"),
Member.of(DIMENSION_RPS2_NAME, "e2"),
Member.of(DIMENSION_RPS2_NAME, "e3")])).to_mdx()
values = self.tm1.cubes.cells.execute_mdx_values(mdx)
self.assertEqual(next(values), 2)
self.assertEqual(next(values), 4)
self.assertEqual(next(values), 6)
def test_execute_view_rows_and_values_one_dimension_on_rows(self):
view_name = PREFIX + "MDX_View_With_One_Dim_On_Rows"
if not self.tm1.cubes.views.exists(cube_name=CUBE_NAME, view_name=view_name, private=False):
mdx = MdxBuilder.from_cube(CUBE_NAME).add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[0], "Element1"),
Member.of(DIMENSION_NAMES[0], "Element2")])) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.members([
Member.of(DIMENSION_NAMES[1], "Element1"),
Member.of(DIMENSION_NAMES[1], "Element2"),
Member.of(DIMENSION_NAMES[1], "Element3")])) \
.where(Member.of(DIMENSION_NAMES[2], "Element1")) \
.to_mdx()
view = MDXView(cube_name=CUBE_NAME, view_name=view_name, MDX=mdx)
self.tm1.cubes.views.create(view, False)
data = self.tm1.cubes.cells.execute_view_rows_and_values(
cube_name=CUBE_NAME,
view_name=view_name,
private=False)
self.assertEqual(len(data), 2)
for row, cells in data.items():
('e1', 'e1'): 1,
('e1', 'e2'): 2,
('e1', 'e3'): 3,
}
self.tm1.cubes.cells.write_values(CUBE_RPS2_NAME, cells)
self.tm1.cubes.cells.relative_proportional_spread(
value=12,
cube=CUBE_RPS1_NAME,
unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[e2]", "[" + DIMENSION_RPS2_NAME + "].[c1]"),
reference_cube=CUBE_RPS2_NAME,
reference_unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[c1]", "[" + DIMENSION_RPS2_NAME + "].[c1]"))
mdx = MdxBuilder.from_cube(CUBE_RPS1_NAME) \
.add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_RPS1_NAME, "e2"))) \
.add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
Member.of(DIMENSION_RPS2_NAME, "e1"),
Member.of(DIMENSION_RPS2_NAME, "e2"),
Member.of(DIMENSION_RPS2_NAME, "e3")])).to_mdx()
values = self.tm1.cubes.cells.execute_mdx_values(mdx)
self.assertEqual(next(values), 2)
self.assertEqual(next(values), 4)
self.assertEqual(next(values), 6)