Skip to content

Commit

Permalink
Update test ref logs for mondrian change which emits '[All Xxxx] in m…
Browse files Browse the repository at this point in the history
…ember

unique names.

Upgrade version of mondrian used for testing.

In API spec, make it clear that a CellSet always has a filter axis, and that
the filter axis contains only members explicitly mentioned in WHERE clause.
Change XMLA driver to match. (Driver in latest mondrian also complies.)

Remove unused field and params from parser and DefaultMdxParserImpl.


git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@310 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Apr 23, 2010
1 parent 73e4db4 commit 041d119
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 268 deletions.
2 changes: 1 addition & 1 deletion ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<dependency org="hsqldb" name="hsqldb" rev="1.8.0.7"
transitive="false" conf="test->default" />

<dependency org="pentaho" name="mondrian" rev="3.2.0.13406"
<dependency org="pentaho" name="mondrian" rev="3.2.0.13571"
transitive="false" changing="true" conf="test->default" />

<dependency org="eigenbase" name="eigenbase-xom" rev="1.3.0.11999"
Expand Down
15 changes: 11 additions & 4 deletions src/org/olap4j/CellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// 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.
// Copyright (C) 2006-2008 Julian Hyde
// Copyright (C) 2006-2010 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -15,7 +15,7 @@
/**
* Result of executing an OLAP Statement.
*
* <p>An <codeOlapResultSet</code> consists of a set of (typically two) axes,
* <p>A <code>CellSet</code> consists of a set of (typically two) axes,
* each populated with a sequence of members, and a collection of cells at the
* intersection of these axes.
*
Expand Down Expand Up @@ -71,17 +71,24 @@ public interface CellSet extends ResultSet, OlapWrapper {
* axis, 1 the rows axis, and so forth.
*
* @return list of CellSetAxis objects containing the result
*
* @see #getFilterAxis()
*/
List<CellSetAxis> getAxes();

/**
* Retrieves the CellSetAxis representing the filter axis.
*
* <p>This axis always has one row, and contains one member for each
* dimension not included in any other axis. Some of these dimensions may
* <p>This axis always has one position, and members of
* dimensions not included in any other axis. Some of these dimensions may
* have been explicitly mentioned in the WHERE clause of the MDX statement;
* others dimensions are represented by their default member.
*
* <p>In particular, if the query has no WHERE clause, the axis has a single
* position as usual, but the position has no members.
*
* <p>The filter axis is not included in the {@link #getAxes()} collection.
*
* @return the filter axis
*/
CellSetAxis getFilterAxis();
Expand Down
35 changes: 29 additions & 6 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class XmlaOlap4jCellSet implements CellSet {
*
* @return Error handler
*/
private final XmlaHelper getHelper() {
private XmlaHelper getHelper() {
return olap4jStatement.olap4jConnection.helper;
}

Expand Down Expand Up @@ -221,8 +221,10 @@ void populate() throws OlapException {
for (Element axisNode : findChildren(axesNode, MDDATASET_NS, "Axis")) {
final String axisName = axisNode.getAttribute("name");
final Axis axis = lookupAxis(axisName);
final ArrayList<Position> positions = new ArrayList<Position>();
final XmlaOlap4jCellSetAxis cellSetAxis =
new XmlaOlap4jCellSetAxis(this, axis);
new XmlaOlap4jCellSetAxis(
this, axis, Collections.unmodifiableList(positions));
if (axis.isFilter()) {
filterAxis = cellSetAxis;
} else {
Expand Down Expand Up @@ -270,12 +272,25 @@ void populate() throws OlapException {
}
members.add(member);
}
cellSetAxis.positions.add(
positions.add(
new XmlaOlap4jPosition(
members, cellSetAxis.positions.size()));
members, positions.size()));
}
}

// olap4j requires a filter axis even if XMLA does not return one. If
// XMLA does not return one, presumably there was no WHERE clause and
// therefore the filter axis has a single position containing 0 members
if (filterAxis == null) {
filterAxis =
new XmlaOlap4jCellSetAxis(
this,
Axis.FILTER,
Collections.<Position>singletonList(
new XmlaOlap4jPosition(
Collections.<Member>emptyList(), 0)));
}

final Element cellDataNode = findChild(root, MDDATASET_NS, "CellData");
for (Element cell : findChildren(cellDataNode, MDDATASET_NS, "Cell")) {
propertyValues.clear();
Expand Down Expand Up @@ -469,6 +484,14 @@ private XmlaOlap4jCellSetMetaData createMetaData(Element root)
axisMetaDataList.add(axisMetaData);
}
}
if (filterAxisMetaData == null) {
filterAxisMetaData =
new XmlaOlap4jCellSetAxisMetaData(
olap4jStatement.olap4jConnection,
Axis.FILTER,
Collections.<Hierarchy>emptyList(),
Collections.<XmlaOlap4jCellSetMemberProperty>emptyList());
}
final Element cellInfo =
findChild(olapInfo, MDDATASET_NS, "CellInfo");
List<XmlaOlap4jCellProperty> cellProperties =
Expand Down Expand Up @@ -497,7 +520,7 @@ private XmlaOlap4jCellSetMetaData createMetaData(Element root)
* @param databaseMetaData Database metadata
* @param cubeName Cube name
* @return Cube, or null if not found
* @throws OlapException
* @throws OlapException on error
*/
private XmlaOlap4jCube lookupCube(
XmlaOlap4jDatabaseMetaData databaseMetaData,
Expand All @@ -524,7 +547,7 @@ private XmlaOlap4jCube lookupCube(
* @param cube Cube
* @param hierarchyName Name (or unique name) of hierarchy.
* @return Hierarchy
* @throws OlapException
* @throws OlapException on error
*/
private Hierarchy lookupHierarchy(XmlaOlap4jCube cube, String hierarchyName)
throws OlapException
Expand Down
13 changes: 7 additions & 6 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxis.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@
class XmlaOlap4jCellSetAxis implements CellSetAxis {
private final XmlaOlap4jCellSet olap4jCellSet;
private final Axis axis;
final List<Position> positions = new ArrayList<Position>();
private final List<Position> immutablePositions =
Collections.unmodifiableList(positions);
final List<Position> positions;

/**
* Creates an XmlaOlap4jCellSetAxis.
*
* @param olap4jCellSet Cell set
* @param axis Axis identifier
* @param positions List of positions. Caller must ensure it is immutable
*/
public XmlaOlap4jCellSetAxis(
XmlaOlap4jCellSet olap4jCellSet,
Axis axis)
Axis axis,
List<Position> positions)
{
this.olap4jCellSet = olap4jCellSet;
this.axis = axis;
this.positions = positions;
}

public Axis getAxisOrdinal() {
Expand All @@ -60,15 +61,15 @@ public CellSetAxisMetaData getAxisMetaData() {
}

public List<Position> getPositions() {
return immutablePositions;
return positions;
}

public int getPositionCount() {
return positions.size();
}

public ListIterator<Position> iterator() {
return immutablePositions.listIterator();
return positions.listIterator();
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/org/olap4j/mdx/parser/impl/DefaultMdxParser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ parser code {:
Scanner scanner;
private String queryString;
private DefaultMdxParserImpl.FunTable funTable;
private boolean load;

/**
* Recursively parses an expression.
Expand All @@ -38,14 +37,12 @@ parser code {:
SelectNode parseSelect(
String queryString,
boolean debug,
DefaultMdxParserImpl.FunTable funTable,
boolean load)
DefaultMdxParserImpl.FunTable funTable)
{
Symbol parse_tree = null;
this.scanner = new StringScanner(queryString, debug);
this.queryString = queryString;
this.funTable = funTable;
this.load = load;
try {
if (debug) {
parse_tree = debug_parse();
Expand Down
13 changes: 4 additions & 9 deletions src/org/olap4j/mdx/parser/impl/DefaultMdxParserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.olap4j.mdx.parser.MdxParser;
import org.olap4j.mdx.SelectNode;
import org.olap4j.mdx.ParseTreeNode;
import org.olap4j.OlapConnection;

/**
* Default implementation of {@link org.olap4j.mdx.parser.MdxParser MDX Parser}.
Expand All @@ -23,18 +22,15 @@
*/
public class DefaultMdxParserImpl implements MdxParser {
private boolean debug = false;
private boolean load = false;
private final FunTable funTable = new FunTable() {
public boolean isProperty(String s) {
return s.equals("CHILDREN");
}
};

@Deprecated
public DefaultMdxParserImpl(OlapConnection olapConnection) {
super();
}

/**
* Creates a DefaultMdxParserImpl.
*/
public DefaultMdxParserImpl() {
super();
}
Expand All @@ -43,8 +39,7 @@ public SelectNode parseSelect(String mdx) {
return new DefaultMdxParser().parseSelect(
mdx,
debug,
funTable,
load);
funTable);
}

public ParseTreeNode parseExpression(String mdx) {
Expand Down
Loading

0 comments on commit 041d119

Please sign in to comment.