use of mondrian.olap.Axis in project pentaho-kettle by pentaho.
the class MondrianHelper method outputFlattenedRecurse.
private static void outputFlattenedRecurse(Result result, List<List<Object>> rows, List<Object> rowValues, int[] coords, int axisOrdinal) {
final Axis[] axes = result.getAxes();
if (axisOrdinal == axes.length) {
final Cell cell = result.getCell(coords);
// Output the raw (unformatted) value of the cell.
// NOTE: We could output other properties of the cell here, such as its
// formatted value, too.
rowValues.add(cell.getValue());
// Add a copy of the completed row to the list of rows.
rows.add(new ArrayList<>(rowValues));
} else {
final Axis axis = axes[axisOrdinal];
int k = -1;
int saveLength = rowValues.size();
for (Position position : axis.getPositions()) {
coords[axisOrdinal] = ++k;
for (Member member : position) {
rowValues.add(member.getUniqueName());
}
outputFlattenedRecurse(result, rows, rowValues, coords, axisOrdinal + 1);
while (rowValues.size() > saveLength) {
rowValues.remove(rowValues.size() - 1);
}
}
}
}
use of mondrian.olap.Axis in project mondrian by pentaho.
the class MultipleColsInTupleAggTest method testNativeFilterWithoutMeasuresAndLevelWithProps.
public void testNativeFilterWithoutMeasuresAndLevelWithProps() throws Exception {
if (!isApplicable()) {
return;
}
// similar to the previous test, but verifies a case where
// a level property is the extra column that requires joining
// agg star back to the dim table. This test also uses the bottom
// level of the dim
final String query = "select " + "Filter([Product].[Product Name].members, " + "Product.CurrentMember.Caption MATCHES (\"(?i).*Two.*\") )" + " on columns " + "from [Fact] ";
getTestContext().assertQueryReturns(query, "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Product].[Cat One].[Prod Cat One].[Two]}\n" + "Row #0: 6\n");
// check generated sql only for native evaluation
if (MondrianProperties.instance().EnableNativeFilter.get()) {
assertQuerySql(query, new SqlPattern[] { new SqlPattern(Dialect.DatabaseProduct.MYSQL, "select\n" + " `cat`.`cat` as `c0`,\n" + " `cat`.`cap` as `c1`,\n" + " `cat`.`ord` as `c2`,\n" + " `cat`.`name3` as `c3`,\n" + " `product_cat`.`name2` as `c4`,\n" + " `product_cat`.`cap` as `c5`,\n" + " `product_cat`.`ord` as `c6`,\n" + " `test_lp_xx2_fact`.`prodname` as `c7`,\n" + " `product_csv`.`color` as `c8`\n" + "from\n" + " `product_csv` as `product_csv`,\n" + " `product_cat` as `product_cat`,\n" + " `cat` as `cat`,\n" + " `test_lp_xx2_fact` as `test_lp_xx2_fact`\n" + "where\n" + " `product_cat`.`cat` = `cat`.`cat`\n" + "and\n" + " `product_csv`.`prod_cat` = `product_cat`.`prod_cat`\n" + "and\n" + " `product_csv`.`name1` = `test_lp_xx2_fact`.`prodname`\n" + "group by\n" + " `cat`.`cat`,\n" + " `cat`.`cap`,\n" + " `cat`.`ord`,\n" + " `cat`.`name3`,\n" + " `product_cat`.`name2`,\n" + " `product_cat`.`cap`,\n" + " `product_cat`.`ord`,\n" + " `test_lp_xx2_fact`.`prodname`,\n" + " `product_csv`.`color`\n" + "having\n" + " c7 IS NOT NULL AND UPPER(c7) REGEXP '.*TWO.*'\n" + "order by\n" + (TestContext.instance().getDialect().requiresOrderByAlias() ? " ISNULL(`c2`) ASC, `c2` ASC,\n" + " ISNULL(`c6`) ASC, `c6` ASC,\n" + " ISNULL(`c7`) ASC, `c7` ASC" : " ISNULL(`cat`.`ord`) ASC, `cat`.`ord` ASC,\n" + " ISNULL(`product_cat`.`ord`) ASC, `product_cat`.`ord` ASC,\n" + " ISNULL(`test_lp_xx2_fact`.`prodname`) ASC, " + "`test_lp_xx2_fact`.`prodname` ASC"), null) });
}
Axis axis = getTestContext().withCube("Fact").executeAxis("Filter([Product].[Product Name].members, " + "Product.CurrentMember.Caption MATCHES (\"(?i).*Two.*\") )");
assertEquals("Member property value was not loaded correctly.", "Black", ((RolapAxis) axis).getTupleList().get(0).get(0).getPropertyValue("Product Color"));
}
use of mondrian.olap.Axis in project mondrian by pentaho.
the class BasicQueryTest method testAllMemberCaption.
public void testAllMemberCaption() {
TestContext testContext = TestContext.instance().createSubstitutingCube("Sales", "<Dimension name=\"Gender3\" foreignKey=\"customer_id\">\n" + " <Hierarchy hasAll=\"true\" allMemberName=\"All Gender\"\n" + " allMemberCaption=\"Frauen und Maenner\" primaryKey=\"customer_id\">\n" + " <Table name=\"customer\"/>\n" + " <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\"/>\n" + " </Hierarchy>\n" + "</Dimension>");
String mdx = "select {[Gender3].[All Gender]} on columns from Sales";
Result result = testContext.executeQuery(mdx);
Axis axis0 = result.getAxes()[0];
Position pos0 = axis0.getPositions().get(0);
Member allGender = pos0.get(0);
String caption = allGender.getCaption();
Assert.assertEquals(caption, "Frauen und Maenner");
}
use of mondrian.olap.Axis in project mondrian by pentaho.
the class BasicQueryTest method testAllLevelName.
public void testAllLevelName() {
TestContext testContext = TestContext.instance().createSubstitutingCube("Sales", "<Dimension name=\"Gender4\" foreignKey=\"customer_id\">\n" + " <Hierarchy hasAll=\"true\" allMemberName=\"All Gender\"\n" + " allLevelName=\"GenderLevel\" primaryKey=\"customer_id\">\n" + " <Table name=\"customer\"/>\n" + " <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\"/>\n" + " </Hierarchy>\n" + "</Dimension>");
String mdx = "select {[Gender4].[All Gender]} on columns from Sales";
Result result = testContext.executeQuery(mdx);
Axis axis0 = result.getAxes()[0];
Position pos0 = axis0.getPositions().get(0);
Member allGender = pos0.get(0);
String caption = allGender.getLevel().getName();
Assert.assertEquals(caption, "GenderLevel");
}
use of mondrian.olap.Axis in project mondrian by pentaho.
the class BasicQueryTest method testNonEmptyCrossJoin.
/**
* Tests a query with a CrossJoin so large that we run out of memory unless
* we can push down evaluation to SQL.
*/
public void testNonEmptyCrossJoin() {
if (!props.EnableNativeCrossJoin.get()) {
// memory.
return;
}
TestContext.instance().flushSchemaCache();
Result result = executeQuery("select {[Measures].[Store Sales]} on columns,\n" + " NON EMPTY Crossjoin(\n" + " [Customers].[Name].Members,\n" + " [Product].[Product Name].Members\n" + " ) ON rows\n" + "from [Sales]\n" + "where (\n" + " [Store].[All Stores].[USA].[CA].[San Francisco].[Store 14],\n" + " [Time].[1997].[Q1].[1]\n" + ")\n");
// ok if no OutOfMemoryError occurs
Axis a = result.getAxes()[1];
assertEquals(67, a.getPositions().size());
}
Aggregations