Real time OLAP with Mondrian
Mondrian is an open-source OLAP server which offers a XMLA interface to send MDX queries. Multi-dimensional cubes are defined logically in Mondrian and are mapped physically to a relational database. Cubes are calculated on demand in EXASolution and are cached in Mondrian for further queries. Pre-aggregation of data is no longer an issue and fast real time OLAP is possible in combination with EXASolution. The standardized XMLA interface offers easy integration into existing reporting and analysis tools.
In the following article we we will define a cube using the Mondrian Schema Workbench and publish it on the Mondrian Server using the XMLA interface. You can download a preconfigured Mondrian package including Tomcat here.

- MDX-Schnittstelle über Mondrian
Definition of a cube through Mondrian Schema Workbench
A multi dimensional database consisting of the logical model (cubes, hierarchies and measures) and the mapping to the relational database is defined in a Mondrian schema, a description in XML.
The Mondrian Schema Workbench is a graphical development tool to create and validate such a schema. The tool also checks whether the mapping to the relational database is correct. Additionally it has a simple interface to send MDX queries against the created schema.
Download the newest version of the workbench and the EXASolution JDBC driver. You should have also installed a JRE 6. Unpack the Workbench and copy jdbc14.jar into the folder WORKBENCH_HOME/drivers.
You can start the Workbench with the script workbench.bat respectively workbench.sh. Create the connection to EXASolution under Options->Connection... . Choose "generic database" as connection type, as access "Native JDBC" as custom connection "jdbc:exa:<connection string>", as custom driver class "com.exasol.jdbc.EXADriver" and enter your username and password. Press the test button to check if the connection to EXASolution succeeds.
Open the file TPCH1.xml in the workbench. Our example is based on the relational TPC-H schema from the TPC-H Benchmark , which is part of our demo system. The schema editor is split in two areas:
On the left-hand side is a tree that shows the structure of the schema while the right part shows the attributes of selected elements. The toolbar on the top has various buttons to create new elements like cubes, dimensions etc.
Our predefined schema consists of two cubes: Q1 and Q2. A cube consists of a fact table and several dimensions and measures. The cube Q2 is based on the fact table ORDERS and has a dimension "customer" with the hierarchies "region" and "nation". The dimension table for this hierarchy is a nested join over the tables CUSTOMER,NATION and REGION (a standard Mondrian-construct, see screenshot). The dimension table is linked to the fact table ORDERS via the foreign key C_CUSTKEY. A typical OLAP time dimension consisting of year, quarter and month is defined over a temporary view of the column O_ORDERDATE from the table ORDERS:
-
- WITH ORDERDATE (FULLDATE,M,Q,Y) AS (
- SELECT
- O_ORDERDATE,
- TO_CHAR(O_ORDERDATE, 'MM') ,
- TO_CHAR(O_ORDERDATE, 'Q'),
- TO_CHAR(O_ORDERDATE, 'YYYY')
- FROM
- TPC.ORDERS
- )
- SELECT DISTINCT * FROM ORDERDATE;
Based on this view we will define the hierarchies year, quarter and month. Q2 also contains the measure 'Sum TotalPrice' which is defined with the aggregator sum using the column O_TOTALPRICE of the fact table ORDERS.
The workbench automatically validates the used columns and tables against the physical database schema. This secures that the mapping is working in the productive implementation. MDX queries can be sent directly to our defined schema with a small tool found under File->New->MDX-Query We will send a MDX query that calculates 'Sum TotalPrice' for the years 1992, 1993, 1994 of the regions AFRICA, ASIA and EUROPE:
-
- SELECT {[Orderdate].[1992],
- [Orderdate].[1993],
- [Orderdate].[1994]} ON COLUMNS,
- {[Customer].[AFRICA ],
- [Customer].[ASIA ],
- [Customer].[EUROPE ]}
- ON ROWS
- FROM [Q2]
- WHERE [Measures].[SUM TotalPrice]
Additional information about the definition of mondrian schemas can be found on the Mondrian Documentation website.
Publication of the cube and setup of the XMLA interface
If you haven't yet downloaded the preconfigured Tomcat/Mondrian package, please download it now and unpack it. The package already contains the preconfigured schema file TPCH1.xml in the folder TOMCAT_HOME/webapps/mondrian/WEB-INF/queries.
To configure the XMLA interface we will edit the file TOMCAT_HOME/webapps/mondrian/WEB-INF/DataSources.xml.
We define the name of the DataSource as 'Provider=Mondrian;DataSource=TPCH' and the URL of the XMLA interface as 'http://localhost:8080/mondrian/xmla'. The JDBC connection to EXASolution is defined in the element 'DataSourceInfo'. Please edit username and password as required. Finally we define the Catalog TPCH with the URI to the schema definition file TPCH1.xml. The complete DataSources.xml looks like this:
-
- <?xml version="1.0"?>
- <DataSources>
- <DataSource>
- <DataSourceName>Provider=Mondrian;DataSource=TPCH;</DataSourceName>
- <DataSourceDescription>TPCH</DataSourceDescription>
- <URL>http://localhost:8080/mondrian/xmla</URL>
- <DataSourceInfo>Provider=mondrian;
- Jdbc=jdbc:exa:212.204.74.3..8:8563;
- JdbcUser=test;JdbcPassword=password;
- JdbcDrivers=com.exasol.jdbc.EXADriver;
- Catalog=/WEB-INF/queries/TPCH1.xml
- </DataSourceInfo>
- <ProviderName>Mondrian</ProviderName>
- <ProviderType>MDP</ProviderType>
- <AuthenticationMode>Unauthenticated</AuthenticationMode>
- <Catalogs>
- <Catalog name="TPCH">
- <Definition>/WEB-INF/queries/TPCH1.xml</Definition>
- </Catalog>
- </Catalogs>
- </DataSource>
- </DataSources>
Testing the XMLA interface with JPivot
We will now test the configured XMLA interface with the OLAP web application JPivot. JPivot is part of the standard Mondrian package. Before the test you can modify the file TOMCAT_HOME/webapps/mondrian/WEB-INF/queries/xmla.jsp, for example to change the sample mdx query, the XMLA URL or the used catalog. The complete xmla.jsp looks as follows:
-
- <%@ page session="true" pageEncoding="UTF-8" contentType="text/html; charset=ISO-8859-1" %>
- <%@ taglib uri="http://www.tonbeller.com/jpivot" prefix="jp" %>
- <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
- <!--
- * Change uri attribute to your deployment of this webapp.
- * The dataSource attribute is necessary for Mondrian's XMLA.
- -->
- <jp:xmlaQuery id="query01"
- uri="http://localhost:8080/mondrian/xmla"
- dataSource="Provider=Mondrian;DataSource=TPCH;"
- catalog="TPCH">
- select {[Orderdate].[1992],[Orderdate].[1993],[Orderdate].[1994]} ON COLUMNS,
- {[Customer].[AFRICA ],
- [Customer].[ASIA ],
- [Customer].[EUROPE ]}
- ON ROWS from [Q2] where [Measures].[Sum TotalPrice]
- </jp:xmlaQuery>
- <c:set var="title01" scope="session">Accessing Mondrian powered by EXASolution by XMLA</c:set>
Set the environment variable JAVA_HOME to the according path, for example SET JAVA_HOME=C:\jre16 on Windows systems respectivly EXPORT JAVA_HOME=/user/bin/jre on Linux/Unix systems. Start the Tomcat application server with the script TOMCAT_HOME/bin/startup.sh respectivly startup.bat and point your webbrowser to localhost/mondrian/testpage.jsp, to test the XMLA interface with JPivot. The result of our sample MDX query is showed as a table.
Thereby we secured that the XMLA interface works correctly. As a next step you can connect your reporting- or analysis tool with the XMLA interface. When you connect your tool at the XMLA interface at 'http://localhost:8080/mondrian/xmla' you can use your OLAP tool with EXASolution as backend and profit from the performance gain and additional flexibility. Your cubes are calculated on the fly.




















