String mdx = "with member measures.type as '"
+ castedType + "' "
+ "select measures.type on 0 from sales";
CellSet olap4jXmlaCellset = context.executeOlap4jXmlaQuery(mdx);
CellSet olap4jCellset = context.executeOlap4jQuery(mdx);
Result nativeMondrianResult = context.executeQuery(mdx);
assertEquals(
"Checking olap4jXmla datatype against native Mondrian. \n"
+ "Unexpected datatype when running mdx " + mdx + "\n",
nativeMondrianResult.getCell(new int[]{0})
.getValue().getClass(),
olap4jXmlaCellset.getCell(0).getValue().getClass());
assertEquals(
"Checking olap4jXmla datatype against native Mondrian. \n"
+ "Unexpected datatype when running mdx " + mdx + "\n",
olap4jXmlaCellset.getCell(0).getValue().getClass(),
olap4jCellset.getCell(0).getValue().getClass());
}
RolapCube cube =
(RolapCube)context.executeQuery("select from sales")
.getQuery().getCube();
Dialect dialect = cube.getStar().getSqlQueryDialect();
if (!dialect.getDatabaseProduct()
.equals(Dialect.DatabaseProduct.MYSQL)
&& !dialect.getDatabaseProduct()
.equals(Dialect.DatabaseProduct.ORACLE))
{
return;
}
// map of sql expressions to the corresponding (optional) datatype
// attribute (RolapBaseCubeMeasure.Datatype)
Map<String, String> expressionTypeMap = new HashMap<String, String>();
expressionTypeMap.put("'StringValue'", "String");
expressionTypeMap.put("cast(1.0001 as decimal)", null);
expressionTypeMap.put("cast(1.0001 as decimal)", "Numeric");
expressionTypeMap.put("cast(10.101 as decimal(10,8))", null);
expressionTypeMap.put("cast(10.101 as decimal(10,8))", "Numeric");
for (String expression : expressionTypeMap.keySet()) {
String query = "Select measures.typeMeasure on 0 from Sales";
context = getContextWithMeasureExpression(
expression, expressionTypeMap.get(expression));
CellSet olap4jXmlaCellset = context.executeOlap4jXmlaQuery(query);
CellSet olap4jCellset = context.executeOlap4jQuery(query);
Result nativeMondrianResult = context.executeQuery(query);
assertEquals(
"Checking olap4jXmla datatype against native Mondrian. \n"
+ "Unexpected datatype for measure expression " + expression
+ " with datatype attribute "
+ expressionTypeMap.get(expression) + "\n",
nativeMondrianResult.getCell(new int[]{0})
.getValue().getClass(),
olap4jXmlaCellset.getCell(0).getValue().getClass());
assertEquals(
"Checking olap4jXmla datatype against olap4j in process. \n"
+ "Unexpected datatype for expression " + expression