Skip to content

Commit

Permalink
MONDRIAN: Enable dialect for Infobright 3.1 (fixes bug 2645300).
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 12402]
  • Loading branch information
julianhyde committed Mar 2, 2009
1 parent 0179be7 commit 5cc8a26
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 21 deletions.
7 changes: 6 additions & 1 deletion bin/loadFoodMart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ Linux) PS=: ;;
*) PS=\; ;;
esac

export CP="lib/mondrian.jar${PS}lib/log4j.jar${PS}lib/eigenbase-properties.jar${PS}lib/eigenbase-xom.jar${PS}lib/eigenbase-resgen.jar"
export CP="lib/mondrian.jar"
export CP="${CP}${PS}lib/log4j.jar"
export CP="${CP}${PS}lib/commons-logging.jar"
export CP="${CP}${PS}lib/eigenbase-properties.jar"
export CP="${CP}${PS}lib/eigenbase-xom.jar"
export CP="${CP}${PS}lib/eigenbase-resgen.jar"

oracle() {
#export ORACLE_HOME=G:/oracle/product/10.1.0/Db_1
Expand Down
10 changes: 5 additions & 5 deletions doc/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
== Agreement, available at the following URL:
== http://www.opensource.org/licenses/cpl.html.
== Copyright (C) 2001-2002 Kana Software, Inc.
== Copyright (C) 2002-2008 Julian Hyde and others
== Copyright (C) 2002-2009 Julian Hyde and others
== All Rights Reserved.
== You must accept the terms of that agreement to use this software.
-->
Expand Down Expand Up @@ -259,7 +259,7 @@ <h4>Options</h4>
</tbody>
</table>

<h4>Examples</h4>
<h4>Examples<a name="2_3_Examples">&nbsp;</a></h4>

<p>Here are some examples to give you a general idea how
<code>MondrianFoodMartLoader</code> is invoked. The command line you use
Expand Down Expand Up @@ -289,7 +289,7 @@ <h5>Example 1. Loading MySQL from a file on Linux<a name="MySQL_on_Linux_example

<blockquote>
<code><b><i>$</i></b> java -cp
"/mondrian/lib/mondrian.jar:/mondrian/lib/log4j.jar:/mondrian/lib/eigenbase-xom.jar:/mondrian/lib/eigenbase-resgen.jar:/mondrian/lib/eigenbase-properties.jar:/usr/local/mysql/mysql-connector-java-5.0.5-bin.jar"<br>
"/mondrian/lib/mondrian.jar:/mondrian/lib/log4j.jar:/mondrian/lib/commons-logging.jar:/mondrian/lib/eigenbase-xom.jar:/mondrian/lib/eigenbase-resgen.jar:/mondrian/lib/eigenbase-properties.jar:/usr/local/mysql/mysql-connector-java-5.0.5-bin.jar"<br>
&nbsp;&nbsp;&nbsp;&nbsp; mondrian.test.loader.MondrianFoodMartLoader<br>
&nbsp;&nbsp;&nbsp;&nbsp; -verbose -tables -data -indexes<br>
&nbsp;&nbsp;&nbsp;&nbsp; -jdbcDrivers=com.mysql.jdbc.Driver<br>
Expand All @@ -305,7 +305,7 @@ <h5>Example 2. Loading PostgreSQL from Access on Windows<a name="PostgreSQL_on_W

<blockquote>
<code><i><b>C:\mondrian&gt;</b></i> java -cp
"C:\mondrian\lib\mondrian.jar;C:\mondrian\lib\log4j.jar; C:\mondrian\lib\eigenbase-xom.jar; C:\mondrian\lib\eigenbase-resgen.jar; C:\mondrian\lib\eigenbase-properties.jar; C:\mondrian\lib\postgres-jdbc.jar"<br>
"C:\mondrian\lib\mondrian.jar; C:\mondrian\lib\log4j.jar; C:\mondrian\lib\commons-logging.jar; C:\mondrian\lib\eigenbase-xom.jar; C:\mondrian\lib\eigenbase-resgen.jar; C:\mondrian\lib\eigenbase-properties.jar; C:\mondrian\lib\postgres-jdbc.jar"<br>
&nbsp;&nbsp;&nbsp;&nbsp; mondrian.test.loader.MondrianFoodMartLoader<br>
&nbsp;&nbsp;&nbsp;&nbsp; -verbose -tables -data -indexes<br>
&nbsp;&nbsp;&nbsp;&nbsp; -jdbcDrivers="org.postgresql.Driver,sun.jdbc.odbc.JdbcOdbcDriver"<br>
Expand Down Expand Up @@ -636,7 +636,7 @@ <h3>8.2. Log4j and Tomcat<a name="8_2_Log4j_and_Tomcat">&nbsp;</a></h3>
Version: $Id$
(<a href="http://p4web.eigenbase.org/open/mondrian/doc/install.html?ac=22">log</a>)<br/>
Copyright (C) 2001-2002 Kana Software, Inc.<br/>
Copyright (C) 2002-2008 Julian Hyde and others
Copyright (C) 2002-2009 Julian Hyde and others
</p>

<br/>
Expand Down
1 change: 1 addition & 0 deletions src/main/META-INF/services/mondrian.spi.Dialect
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mondrian.spi.impl.Db2Dialect
mondrian.spi.impl.Db2OldAs400Dialect
mondrian.spi.impl.DerbyDialect
mondrian.spi.impl.FirebirdDialect
mondrian.spi.impl.InfobrightDialect
mondrian.spi.impl.InformixDialect
mondrian.spi.impl.IngresDialect
mondrian.spi.impl.InterbaseDialect
Expand Down
82 changes: 82 additions & 0 deletions src/main/mondrian/spi/impl/InfobrightDialect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
// 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.
// Copyright (C) 2008-2009 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.spi.impl;

import java.sql.Connection;
import java.sql.SQLException;

/**
* Implementation of {@link mondrian.spi.Dialect} for the Infobright database.
*
* @author jhyde
* @version $Id$
* @since Nov 23, 2008
*/
public class InfobrightDialect extends MySqlDialect {

public static final JdbcDialectFactory FACTORY =
new JdbcDialectFactory(
InfobrightDialect.class,
// While we're choosing dialects, this still looks like a MySQL
// connection.
DatabaseProduct.MYSQL);

/**
* Creates an InfobrightDialect.
*
* @param connection Connection
*/
public InfobrightDialect(Connection connection) throws SQLException {
super(connection);
}

public DatabaseProduct getDatabaseProduct() {
return DatabaseProduct.INFOBRIGHT;
}

public boolean allowsCompoundCountDistinct() {
return false;
}

public boolean isNullsCollateLast() {
// Infobright is similar to MySQL, but apparently NULLs collate
// last. This is good news, because the workaround that we use on MySQL
// to force NULLs to collate last would kill Infobright's performance.an
return true;
}

public boolean supportsGroupByExpressions() {
return false;
}

public boolean requiresGroupByAlias() {
return true;
}

public boolean allowsOrderByAlias() {
return false;
}

public boolean requiresOrderByAlias() {
// Actually, Infobright doesn't ALLOW aliases to be used in the ORDER BY
// clause, let alone REQUIRE them. Infobright doesn't allow expressions
// in the ORDER BY clause, so returning true gives the right effect.
return true;
}

public boolean supportsMultiValueInExpr() {
// Infobright supports multi-value IN by falling through to MySQL,
// which is very slow (see for example
// PredicateFilterTest.testFilterAtSameLevel) so we pretend that it
// does not.
return false;
}
}

// End InfobrightDialect.java
24 changes: 23 additions & 1 deletion src/main/mondrian/spi/impl/MySqlDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
package mondrian.spi.impl;

import mondrian.olap.Util;
import mondrian.spi.Dialect;

import javax.sql.DataSource;
import java.util.List;
import java.sql.*;

Expand All @@ -25,7 +27,27 @@ public class MySqlDialect extends JdbcDialectImpl {
public static final JdbcDialectFactory FACTORY =
new JdbcDialectFactory(
MySqlDialect.class,
DatabaseProduct.MYSQL);
DatabaseProduct.MYSQL)
{
@Override
public Dialect createDialect(
DataSource dataSource,
Connection connection)
{
final Dialect dialect =
super.createDialect(
dataSource, connection);
// Infobright looks a lot like MySQL. If this is an Infobright
// connection, yield to the Infobright dialect.
if (dialect != null &&
dialect instanceof MySqlDialect &&
((MySqlDialect) dialect).getDatabaseProduct() ==
DatabaseProduct.INFOBRIGHT) {
return null;
}
return dialect;
}
};

/**
* Creates a MySqlDialect.
Expand Down
31 changes: 17 additions & 14 deletions testsrc/main/mondrian/test/DialectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
public class DialectTest extends TestCase {
private Connection connection;
private Dialect dialect;
private static final
String
INFOBRIGHT_UNSUPPORTED =
"The query includes syntax that is not supported by the Infobright Optimizer. Either restructure the query with supported syntax, or enable the MySQL Query Path in the brighthouse.ini file to execute the query with reduced performance.";

public DialectTest(String name) {
super(name);
Expand Down Expand Up @@ -104,6 +108,8 @@ public void testAllowsCompoundCountDistinct() {
"Syntax error: Encountered \",\" at line 1, column 36.",
// access
"\\[Microsoft\\]\\[ODBC Microsoft Access Driver\\] Syntax error \\(missing operator\\) in query expression '.*'.",
// infobright
INFOBRIGHT_UNSUPPORTED,
// postgres
"ERROR: function count\\(integer, integer\\) does not exist",
// LucidDb
Expand Down Expand Up @@ -254,7 +260,11 @@ public void testRequiresOrderByAlias() {
"FROM [sales_fact_1997]\n" +
"ORDER BY [unit_sales] + [store_id]");
if (getDialect().requiresOrderByAlias()) {
assertQueryFails(sql, new String[] {});
final String[] errs = {
// infobright
INFOBRIGHT_UNSUPPORTED,
};
assertQueryFails(sql, errs);
} else {
assertQuerySucceeds(sql);
}
Expand All @@ -273,7 +283,9 @@ public void testAllowsOrderByAlias() {
// oracle
"(?s)ORA-03001: unimplemented feature.*",
// access
"\\[Microsoft\\]\\[ODBC Microsoft Access Driver\\] Too few parameters. Expected 1."
"\\[Microsoft\\]\\[ODBC Microsoft Access Driver\\] Too few parameters. Expected 1.",
// infobright
INFOBRIGHT_UNSUPPORTED,
};
assertQueryFails(sql, errs);
}
Expand Down Expand Up @@ -336,25 +348,16 @@ public void testSupportsMultiValueInExpr() {
"FROM [sales_fact_1997]\n" +
"WHERE ([unit_sales], [time_id]) IN ((1, 371), (2, 394))");

boolean supports = getDialect().supportsMultiValueInExpr();

// Infobright supports this syntax but is too slow for general use so
// the dialect pretends that it does not.
switch (getDialect().getDatabaseProduct()) {
case INFOBRIGHT:
assertFalse(supports);
supports = true;
break;
}

if (supports) {
if (getDialect().supportsMultiValueInExpr()) {
assertQuerySucceeds(sql);
} else {
String[] errs = {
// derby
"Syntax error: Encountered \",\" at line 3, column 20.",
// access
"\\[Microsoft\\]\\[ODBC Microsoft Access Driver\\] Syntax error \\(comma\\) in query expression '.*'.",
// infobright
INFOBRIGHT_UNSUPPORTED,
// teradata
".*Syntax error, expected something like a 'SELECT' keyword or '\\(' between '\\(' and the integer '1'\\.",
// netezza
Expand Down

0 comments on commit 5cc8a26

Please sign in to comment.