/
BUG_1541077.java
211 lines (171 loc) · 7.37 KB
/
BUG_1541077.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2005-2012 Pentaho and others
// All Rights Reserved.
*/
package mondrian.rolap.aggmatcher;
import mondrian.olap.MondrianProperties;
import mondrian.olap.Result;
/**
* Testcase for
* <a href="http://jira.pentaho.com/browse/MONDRIAN-214">MONDRIAN-214</a>
* (formerly SourceForge bug 1541077)
* and a couple of other aggregate table ExplicitRecognizer conditions.
*
* @author Richard M. Emberson
*/
public class BUG_1541077 extends AggTableTestCase {
private static final String BUG_1541077 = "BUG_1541077.csv";
public BUG_1541077() {
super();
}
public BUG_1541077(String name) {
super(name);
}
public void testStoreCount() throws Exception {
if (!isApplicable()) {
return;
}
MondrianProperties props = MondrianProperties.instance();
// get value without aggregates
propSaver.set(props.UseAggregates, false);
String mdx =
"select {[Measures].[Store Count]} on columns from Cheques";
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();
propSaver.set(props.UseAggregates, true);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();
assertTrue(v.equals(v1));
}
public void testSalesCount() throws Exception {
if (!isApplicable()) {
return;
}
MondrianProperties props = MondrianProperties.instance();
// get value without aggregates
propSaver.set(props.UseAggregates, false);
String mdx =
"select {[Measures].[Sales Count]} on columns from Cheques";
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();
propSaver.set(props.UseAggregates, true);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();
assertTrue(v.equals(v1));
}
public void testTotalAmount() throws Exception {
if (!isApplicable()) {
return;
}
MondrianProperties props = MondrianProperties.instance();
// get value without aggregates
propSaver.set(props.UseAggregates, false);
String mdx =
"select {[Measures].[Total Amount]} on columns from Cheques";
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();
propSaver.set(props.UseAggregates, false);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();
assertTrue(v.equals(v1));
}
public void testBug1541077() throws Exception {
if (!isApplicable()) {
return;
}
MondrianProperties props = MondrianProperties.instance();
// get value without aggregates
propSaver.set(props.UseAggregates, false);
String mdx = "select {[Measures].[Avg Amount]} on columns from Cheques";
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getFormattedValue();
// get value with aggregates
propSaver.set(props.UseAggregates, true);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getFormattedValue();
assertTrue(v.equals(v1));
}
protected String getFileName() {
return BUG_1541077;
}
protected String getCubeDescription() {
return "<Cube name='Cheques'>\n"
+ "<Table name='cheques'>\n"
+ "<AggName name='agg_lp_xxx_cheques'>\n"
+ "<AggFactCount column='FACT_COUNT'/>\n"
+ "<AggForeignKey factColumn='store_id' aggColumn='store_id' />\n"
+ "<AggMeasure name='[Measures].[Avg Amount]'\n"
+ " column='amount_AVG' />\n"
/*
+ "<AggLevel name='[Worker].[Worker]'\n"
+ "column='worker_worker_name'/>\n"
+ "<AggLevel name='[Discount Card].[Discount\n"
+ "Card Type]' column='discount_card_name'/>\n"
+ "<AggLevel name='[Department].[Department]'\n"
+ "column='department_department_name'/>\n"
+ "<AggLevel name='[Department].[Store]'\n"
+ "column='department_store_name'/>\n"
*/
+ "</AggName>\n"
+ "</Table>\n"
/*
+ "<DimensionUsage name='Year' source='Year'\n"
+ " foreignKey='year_id'/>\n"
+ "<DimensionUsage name='Quarter'\n"
+ " source='Quarter' foreignKey='quarter_id'/>\n"
+ "<DimensionUsage name='Month' source='Month'\n"
+ " foreignKey='month_id'/>\n"
+ "<DimensionUsage name='Week' source='Week'\n"
+ " foreignKey='week_id'/>\n"
+ "<DimensionUsage name='WeekDay'\n"
+ " source='WeekDay' foreignKey='weekday_id'/>\n"
+ "<DimensionUsage name='Day' source='Day'\n"
+ " foreignKey='day_id'/>\n"
+ "<DimensionUsage name='Hour' source='Hour'\n"
+ " foreignKey='hour_id'/>\n"
+ "<DimensionUsage name='Worker' source='Worker'\n"
+ " foreignKey='worker_id'/>\n"
+ "<DimensionUsage name='Discount Card'\n"
+ " source='Discount Card' foreignKey='discount_card_id'/>\n"
+ "<DimensionUsage name='Department'\n"
+ " source='Department' foreignKey='department_id'/>\n"
*/
/*
+ "<DimensionUsage name='Store' source='StoreX'\n"
+ " foreignKey='store_id'/>\n"
+ "<DimensionUsage name='Product' source='ProductX'\n"
+ " foreignKey='prod_id'/>\n"
*/
+ "<Dimension name='StoreX' foreignKey='store_id'>\n"
+ " <Hierarchy hasAll='true' primaryKey='store_id'>\n"
+ " <Table name='store_x'/>\n"
+ " <Level name='Store Value' column='value' uniqueMembers='true'/>\n"
+ " </Hierarchy>\n"
+ "</Dimension>\n"
+ "<Dimension name='ProductX' foreignKey='prod_id'>\n"
+ " <Hierarchy hasAll='true' primaryKey='prod_id'>\n"
+ " <Table name='product_x'/>\n"
+ " <Level name='Store Name' column='name' uniqueMembers='true'/>\n"
+ " </Hierarchy>\n"
+ "</Dimension>\n"
+ "<Measure name='Sales Count' \n"
+ " column='prod_id' aggregator='count'\n"
+ " formatString='#,###'/>\n"
+ "<Measure name='Store Count' \n"
+ " column='store_id' aggregator='distinct-count'\n"
+ " formatString='#,###'/>\n"
+ "<Measure name='Total Amount' \n"
+ " column='amount' aggregator='sum'\n"
+ " formatString='#,###'/>\n"
+ "<Measure name='Avg Amount' \n"
+ " column='amount' aggregator='avg'\n"
+ " formatString='00.0'/>\n"
+ "</Cube>";
}
}
// End BUG_1541077.java