Search in sources :

Example 1 with HiveDialect

use of mondrian.spi.impl.HiveDialect in project mondrian by pentaho.

the class DialectTest method testDialectVsDatabaseProduct.

public void testDialectVsDatabaseProduct() throws SQLException {
    final Dialect dialect = getDialect();
    final Dialect.DatabaseProduct databaseProduct = dialect.getDatabaseProduct();
    final DatabaseMetaData databaseMetaData = getConnection().getMetaData();
    switch(databaseProduct) {
        case MARIADB:
            // Dialect has identified that it is MariaDB.
            assertTrue(dialect instanceof MySqlDialect);
            assertFalse(dialect instanceof InfobrightDialect);
            assertTrue(dialect instanceof MariaDBDialect);
            assertFalse(MySqlDialect.isInfobright(databaseMetaData));
            assertEquals("MariaDB", databaseMetaData.getDatabaseProductName());
            break;
        case MYSQL:
            // Dialect has identified that it is MySQL.
            assertTrue(dialect instanceof MySqlDialect);
            assertFalse(dialect instanceof InfobrightDialect);
            assertFalse(MySqlDialect.isInfobright(databaseMetaData));
            assertEquals("MySQL", databaseMetaData.getDatabaseProductName());
            break;
        case HIVE:
            // Dialect has identified that it is Hive.
            assertTrue(dialect instanceof HiveDialect);
            break;
        case INFOBRIGHT:
            // Dialect has identified that it is MySQL.
            assertTrue(dialect instanceof MySqlDialect);
            assertTrue(dialect instanceof InfobrightDialect);
            assertTrue(MySqlDialect.isInfobright(databaseMetaData));
            assertEquals("MySQL", databaseMetaData.getDatabaseProductName());
            break;
        case POSTGRESQL:
            // Dialect has identified that it is PostgreSQL.
            assertTrue(dialect instanceof PostgreSqlDialect);
            assertFalse(dialect instanceof NetezzaDialect);
            assertTrue(databaseMetaData.getDatabaseProductName().indexOf("PostgreSQL") >= 0);
            break;
        case MSSQL:
            // Dialect has identified that it is MSSQL.
            assertTrue(dialect instanceof MicrosoftSqlServerDialect);
            assertTrue(databaseMetaData.getDatabaseProductName().contains("Microsoft"));
            break;
        case NETEZZA:
            // Dialect has identified that it is Netezza and a sub class of
            // PostgreSql.
            assertTrue(dialect instanceof PostgreSqlDialect);
            assertTrue(dialect instanceof NetezzaDialect);
            assertTrue(databaseMetaData.getDatabaseProductName().indexOf("Netezza") >= 0);
            break;
        case NUODB:
            // Dialect has identified that it is NUODB.
            assertTrue(dialect instanceof NuoDbDialect);
            assertTrue(databaseMetaData.getDatabaseProductName().contains("NuoDB"));
            break;
        case GOOGLEBIGQUERY:
            assertTrue(dialect instanceof GoogleBigQueryDialect);
            assertTrue(databaseMetaData.getDatabaseProductName().contains("Google BigQuery"));
            break;
        default:
            // Neither MySQL nor Infobright.
            assertFalse(dialect instanceof MySqlDialect);
            assertFalse(dialect instanceof InfobrightDialect);
            assertNotSame("MySQL", databaseMetaData.getDatabaseProductName());
            break;
    }
}
Also used : MicrosoftSqlServerDialect(mondrian.spi.impl.MicrosoftSqlServerDialect) MariaDBDialect(mondrian.spi.impl.MariaDBDialect) PostgreSqlDialect(mondrian.spi.impl.PostgreSqlDialect) NetezzaDialect(mondrian.spi.impl.NetezzaDialect) HiveDialect(mondrian.spi.impl.HiveDialect) GoogleBigQueryDialect(mondrian.spi.impl.GoogleBigQueryDialect) MicrosoftSqlServerDialect(mondrian.spi.impl.MicrosoftSqlServerDialect) MonetDbDialect(mondrian.spi.impl.MonetDbDialect) HiveDialect(mondrian.spi.impl.HiveDialect) InfobrightDialect(mondrian.spi.impl.InfobrightDialect) Dialect(mondrian.spi.Dialect) PostgreSqlDialect(mondrian.spi.impl.PostgreSqlDialect) NetezzaDialect(mondrian.spi.impl.NetezzaDialect) MariaDBDialect(mondrian.spi.impl.MariaDBDialect) OracleDialect(mondrian.spi.impl.OracleDialect) MySqlDialect(mondrian.spi.impl.MySqlDialect) VectorwiseDialect(mondrian.spi.impl.VectorwiseDialect) NuoDbDialect(mondrian.spi.impl.NuoDbDialect) InfobrightDialect(mondrian.spi.impl.InfobrightDialect) DatabaseMetaData(java.sql.DatabaseMetaData) MySqlDialect(mondrian.spi.impl.MySqlDialect) NuoDbDialect(mondrian.spi.impl.NuoDbDialect) GoogleBigQueryDialect(mondrian.spi.impl.GoogleBigQueryDialect)

Aggregations

DatabaseMetaData (java.sql.DatabaseMetaData)1 Dialect (mondrian.spi.Dialect)1 GoogleBigQueryDialect (mondrian.spi.impl.GoogleBigQueryDialect)1 HiveDialect (mondrian.spi.impl.HiveDialect)1 InfobrightDialect (mondrian.spi.impl.InfobrightDialect)1 MariaDBDialect (mondrian.spi.impl.MariaDBDialect)1 MicrosoftSqlServerDialect (mondrian.spi.impl.MicrosoftSqlServerDialect)1 MonetDbDialect (mondrian.spi.impl.MonetDbDialect)1 MySqlDialect (mondrian.spi.impl.MySqlDialect)1 NetezzaDialect (mondrian.spi.impl.NetezzaDialect)1 NuoDbDialect (mondrian.spi.impl.NuoDbDialect)1 OracleDialect (mondrian.spi.impl.OracleDialect)1 PostgreSqlDialect (mondrian.spi.impl.PostgreSqlDialect)1 VectorwiseDialect (mondrian.spi.impl.VectorwiseDialect)1