Skip to content

Commit

Permalink
MONDRIAN: Fix test exceptions against MySQL, and enable asserts for j…
Browse files Browse the repository at this point in the history
…unit run.

[git-p4: depot-paths = "//open/mondrian/": change = 5780]
  • Loading branch information
julianhyde committed Mar 11, 2006
1 parent 163121b commit d7e4bbf
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 34 deletions.
10 changes: 8 additions & 2 deletions build.xml
Expand Up @@ -3,7 +3,8 @@
== This software is subject to the terms of the Common Public License
== Agreement, available at the following URL:
== http://www.opensource.org/licenses/cpl.html.
== (C) Copyright 2001-2005 Kana Software, Inc. and others.
== (C) Copyright 2001-2004 Kana Software, Inc.
== (C) Copyright 2001-2006 Julian Hyde and others.
== All Rights Reserved.
== You must accept the terms of that agreement to use this software.
-->
Expand Down Expand Up @@ -134,6 +135,9 @@ demo/access/MondrianFoodMart.mdb"/>
<property name="mondrian.foodmart.catalogURL"
value="file:${project.location}/${demo.dir}/FoodMart.xml"/>

<!-- Arguments to the java process spawned by the junit task. -->
<property name="junit.jvmargs" value="-ea -esa"/>

<target name="help">
<echo>
You must specify a specific project target when using the ANT build.
Expand Down Expand Up @@ -401,7 +405,7 @@ in {mondrian.foodmart.jdbcURL}.">
<echo>Connect String: ${mondrian.test.connectString}</echo>
<java classpathref="project.test.classpath" classname="mondrian.test.Main"
fork="yes">

<jvmarg line="${junit.jvmargs}"/>
<sysproperty key="log4j.configuration"
value="${log4j.configuration}"/>
<sysproperty key="mondrian.jdbcDrivers"
Expand Down Expand Up @@ -918,3 +922,5 @@ xalan.jar"/>

</target>
</project>

<!-- End build.xml -->
5 changes: 2 additions & 3 deletions src/main/mondrian/olap/Query.java
Expand Up @@ -1066,10 +1066,9 @@ public Parameter createOrLookupParam(
private Type getParameterType(final Exp exp, int category) {
switch (category) {
case Category.Member:
case Category.Dimension:
case Category.Hierarchy:
assert exp instanceof DimensionExpr ||
exp instanceof HierarchyExpr;
exp instanceof HierarchyExpr ||
exp instanceof LevelExpr;
return TypeUtil.toMemberType(exp.getType());
case Category.String:
return new StringType();
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/olap/fun/SetFunDef.java
Expand Up @@ -53,7 +53,7 @@ public Type getResultType(Validator validator, Exp[] args) {
for (int i = 0; i < args.length; i++) {
Exp arg = args[i];
Type type = arg.getType();
type = TypeUtil.stripSetType(type);
type = TypeUtil.toMemberOrTupleType(type);
if (i == 0) {
type0 = type;
} else {
Expand Down
80 changes: 52 additions & 28 deletions testsrc/main/mondrian/rolap/TestAggregationManager.java
Expand Up @@ -253,10 +253,11 @@ public void testCountDistinctAggMiss() {
SqlPattern[] patterns = {
new SqlPattern(
SqlPattern.ACCESS_DIALECT,
"select " +
"d0 as `c0`, d1 as `c1`, " +
"count(m0) as `c2`" +
" from (" +
"select" +
" d0 as `c0`," +
" d1 as `c1`," +
" count(m0) as `c2` " +
"from (" +
"select distinct `time_by_day`.`the_year` as `d0`, " +
"`time_by_day`.`quarter` as `d1`, " +
"`sales_fact_1997`.`customer_id` as `m0` " +
Expand All @@ -274,14 +275,16 @@ public void testCountDistinctAggMiss() {
new SqlPattern(
SqlPattern.MY_SQL_DIALECT,
"select" +
" `agg_c_10_sales_fact_1997`.`the_year` as `c0`," +
" `agg_c_10_sales_fact_1997`.`quarter` as `c1`," +
" sum(`agg_c_10_sales_fact_1997`.`customer_count`) as `m0` " +
"from `agg_c_10_sales_fact_1997` as `agg_c_10_sales_fact_1997` " +
"where `agg_c_10_sales_fact_1997`.`the_year` = 1997 " +
"and `agg_c_10_sales_fact_1997`.`quarter` = 'Q1' " +
"group by `agg_c_10_sales_fact_1997`.`the_year`," +
" `agg_c_10_sales_fact_1997`.`quarter`",
" `time_by_day`.`the_year` as `c0`," +
" `time_by_day`.`quarter` as `c1`," +
" count(distinct `sales_fact_1997`.`customer_id`) as `m0` " +
"from `time_by_day` as `time_by_day`," +
" `sales_fact_1997` as `sales_fact_1997` " +
"where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`" +
" and `time_by_day`.`the_year` = 1997" +
" and `time_by_day`.`quarter` = 'Q1' " +
"group by `time_by_day`.`the_year`," +
" `time_by_day`.`quarter`",
26
)
};
Expand All @@ -298,7 +301,7 @@ public void testCountDistinctAggMatch() {

SqlPattern[] patterns = {
new SqlPattern(
SqlPattern.MY_SQL_DIALECT | SqlPattern.ACCESS_DIALECT,
SqlPattern.ACCESS_DIALECT,
"select " +
"`agg_c_10_sales_fact_1997`.`the_year` as `c0`, " +
"`agg_c_10_sales_fact_1997`.`quarter` as `c1`, " +
Expand All @@ -310,7 +313,7 @@ public void testCountDistinctAggMatch() {
"`agg_c_10_sales_fact_1997`.`the_year` = 1997 and " +
"`agg_c_10_sales_fact_1997`.`quarter` = 'Q1' and " +
"`agg_c_10_sales_fact_1997`.`month_of_year` = 1",
26)
26),
};

assertRequestSql(new CellRequest[] {request}, patterns);
Expand All @@ -329,28 +332,49 @@ public void testCountDistinctCannotRollup() {
SqlPattern[] patterns = {
new SqlPattern(
SqlPattern.MY_SQL_DIALECT,
"select `time_by_day`.`the_year` as `c0`," +
"select" +
" `time_by_day`.`the_year` as `c0`," +
" `time_by_day`.`quarter` as `c1`," +
" `time_by_day`.`month_of_year` as `c2`," +
" `store`.`store_country` as `c3`," +
" `product_class`.`product_family` as `c2`," +
" count(distinct `sales_fact_1997`.`customer_id`) as `m0` " +
"from `time_by_day` as `time_by_day`," +
" `sales_fact_1997` as `sales_fact_1997`," +
" `store` as `store` " +
"where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id` " +
"and `time_by_day`.`the_year` = 1997 and `time_by_day`.`quarter` = 'Q1' " +
"and `time_by_day`.`month_of_year` = 1 " +
"and `sales_fact_1997`.`store_id` = `store`.`store_id` " +
"and `store`.`store_country` = 'USA' " +
" `product_class` as `product_class`," +
" `product` as `product` " +
"where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`" +
" and `time_by_day`.`the_year` = 1997" +
" and `time_by_day`.`quarter` = `Q1`" +
" and `sales_fact_1997`.`product_id` = `product`.`product_id`" +
" and `product`.`product_class_id` = `product_class`.`product_class_id`" +
" and `product_class`.`product_family` = `Food` " +
"group by `time_by_day`.`the_year`," +
" `time_by_day`.`quarter`," +
" `time_by_day`.`month_of_year`," +
" `store`.`store_country`",
" `product_class`.`product_family`",
23),
new SqlPattern(
SqlPattern.ACCESS_DIALECT,
"select d0 as `c0`, d1 as `c1`, d2 as `c2`, count(m0) as `c3` from (select distinct `time_by_day`.`the_year` as `d0`, `time_by_day`.`quarter` as `d1`, `product_class`.`product_family` as `d2`, `sales_fact_1997`.`customer_id` as `m0` from `time_by_day` as `time_by_day`, `sales_fact_1997` as `sales_fact_1997`, `product_class` as `product_class`, `product` as `product` where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id` and `time_by_day`.`the_year` = 1997 and `time_by_day`.`quarter` = 'Q1' and `sales_fact_1997`.`product_id` = `product`.`product_id` and `product`.`product_class_id` = `product_class`.`product_class_id` and `product_class`.`product_family` = 'Food') as `dummyname` group by d0, d1, d2",
23)
SqlPattern.ACCESS_DIALECT,
"select" +
" d0 as `c0`," +
" d1 as `c1`," +
" d2 as `c2`," +
" count(m0) as `c3` " +
"from (" +
"select distinct `time_by_day`.`the_year` as `d0`," +
" `time_by_day`.`quarter` as `d1`," +
" `product_class`.`product_family` as `d2`," +
" `sales_fact_1997`.`customer_id` as `m0` " +
"from `time_by_day` as `time_by_day`," +
" `sales_fact_1997` as `sales_fact_1997`," +
" `product_class` as `product_class`," +
" `product` as `product` " +
"where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`" +
" and `time_by_day`.`the_year` = 1997" +
" and `time_by_day`.`quarter` = 'Q1'" +
" and `sales_fact_1997`.`product_id` = `product`.`product_id`" +
" and `product`.`product_class_id` = `product_class`.`product_class_id`" +
" and `product_class`.`product_family` = 'Food') as `dummyname` " +
"group by d0, d1, d2",
23)
};

assertRequestSql(new CellRequest[] {request}, patterns);
Expand Down

0 comments on commit d7e4bbf

Please sign in to comment.