Search in sources :

Example 1 with AccessSqlDialect

use of org.apache.calcite.sql.dialect.AccessSqlDialect in project calcite by apache.

the class SqlDialectFactoryImpl method create.

public SqlDialect create(DatabaseMetaData databaseMetaData) {
    String databaseProductName;
    int databaseMajorVersion;
    int databaseMinorVersion;
    String databaseVersion;
    try {
        databaseProductName = databaseMetaData.getDatabaseProductName();
        databaseMajorVersion = databaseMetaData.getDatabaseMajorVersion();
        databaseMinorVersion = databaseMetaData.getDatabaseMinorVersion();
        databaseVersion = databaseMetaData.getDatabaseProductVersion();
    } catch (SQLException e) {
        throw new RuntimeException("while detecting database product", e);
    }
    final String upperProductName = databaseProductName.toUpperCase(Locale.ROOT).trim();
    final String quoteString = getIdentifierQuoteString(databaseMetaData);
    final NullCollation nullCollation = getNullCollation(databaseMetaData);
    final SqlDialect.Context c = SqlDialect.EMPTY_CONTEXT.withDatabaseProductName(databaseProductName).withDatabaseMajorVersion(databaseMajorVersion).withDatabaseMinorVersion(databaseMinorVersion).withDatabaseVersion(databaseVersion).withIdentifierQuoteString(quoteString).withNullCollation(nullCollation);
    switch(upperProductName) {
        case "ACCESS":
            return new AccessSqlDialect(c);
        case "APACHE DERBY":
            return new DerbySqlDialect(c);
        case "DBMS:CLOUDSCAPE":
            return new DerbySqlDialect(c);
        case "HIVE":
            return new HiveSqlDialect(c);
        case "INGRES":
            return new IngresSqlDialect(c);
        case "INTERBASE":
            return new InterbaseSqlDialect(c);
        case "JETHRODATA":
            return new JethroDataSqlDialect(c.withJethroInfo(jethroCache.get(databaseMetaData)));
        case "LUCIDDB":
            return new LucidDbSqlDialect(c);
        case "ORACLE":
            return new OracleSqlDialect(c);
        case "PHOENIX":
            return new PhoenixSqlDialect(c);
        case "MYSQL (INFOBRIGHT)":
            return new InfobrightSqlDialect(c);
        case "MYSQL":
            return new MysqlSqlDialect(c);
        case "REDSHIFT":
            return new RedshiftSqlDialect(c);
    }
    // Now the fuzzy matches.
    if (databaseProductName.startsWith("DB2")) {
        return new Db2SqlDialect(c);
    } else if (upperProductName.contains("FIREBIRD")) {
        return new FirebirdSqlDialect(c);
    } else if (databaseProductName.startsWith("Informix")) {
        return new InformixSqlDialect(c);
    } else if (upperProductName.contains("NETEZZA")) {
        return new NetezzaSqlDialect(c);
    } else if (upperProductName.contains("PARACCEL")) {
        return new ParaccelSqlDialect(c);
    } else if (databaseProductName.startsWith("HP Neoview")) {
        return new NeoviewSqlDialect(c);
    } else if (upperProductName.contains("POSTGRE")) {
        return new PostgresqlSqlDialect(c);
    } else if (upperProductName.contains("SQL SERVER")) {
        return new MssqlSqlDialect(c);
    } else if (upperProductName.contains("SYBASE")) {
        return new SybaseSqlDialect(c);
    } else if (upperProductName.contains("TERADATA")) {
        return new TeradataSqlDialect(c);
    } else if (upperProductName.contains("HSQL")) {
        return new HsqldbSqlDialect(c);
    } else if (upperProductName.contains("H2")) {
        return new H2SqlDialect(c);
    } else if (upperProductName.contains("VERTICA")) {
        return new VerticaSqlDialect(c);
    } else {
        return new AnsiSqlDialect(c);
    }
}
Also used : H2SqlDialect(org.apache.calcite.sql.dialect.H2SqlDialect) SQLException(java.sql.SQLException) NeoviewSqlDialect(org.apache.calcite.sql.dialect.NeoviewSqlDialect) InformixSqlDialect(org.apache.calcite.sql.dialect.InformixSqlDialect) TeradataSqlDialect(org.apache.calcite.sql.dialect.TeradataSqlDialect) HsqldbSqlDialect(org.apache.calcite.sql.dialect.HsqldbSqlDialect) OracleSqlDialect(org.apache.calcite.sql.dialect.OracleSqlDialect) InterbaseSqlDialect(org.apache.calcite.sql.dialect.InterbaseSqlDialect) AccessSqlDialect(org.apache.calcite.sql.dialect.AccessSqlDialect) SybaseSqlDialect(org.apache.calcite.sql.dialect.SybaseSqlDialect) LucidDbSqlDialect(org.apache.calcite.sql.dialect.LucidDbSqlDialect) IngresSqlDialect(org.apache.calcite.sql.dialect.IngresSqlDialect) JethroDataSqlDialect(org.apache.calcite.sql.dialect.JethroDataSqlDialect) AnsiSqlDialect(org.apache.calcite.sql.dialect.AnsiSqlDialect) MssqlSqlDialect(org.apache.calcite.sql.dialect.MssqlSqlDialect) RedshiftSqlDialect(org.apache.calcite.sql.dialect.RedshiftSqlDialect) VerticaSqlDialect(org.apache.calcite.sql.dialect.VerticaSqlDialect) FirebirdSqlDialect(org.apache.calcite.sql.dialect.FirebirdSqlDialect) InfobrightSqlDialect(org.apache.calcite.sql.dialect.InfobrightSqlDialect) MysqlSqlDialect(org.apache.calcite.sql.dialect.MysqlSqlDialect) NetezzaSqlDialect(org.apache.calcite.sql.dialect.NetezzaSqlDialect) ParaccelSqlDialect(org.apache.calcite.sql.dialect.ParaccelSqlDialect) PostgresqlSqlDialect(org.apache.calcite.sql.dialect.PostgresqlSqlDialect) HiveSqlDialect(org.apache.calcite.sql.dialect.HiveSqlDialect) Db2SqlDialect(org.apache.calcite.sql.dialect.Db2SqlDialect) AnsiSqlDialect(org.apache.calcite.sql.dialect.AnsiSqlDialect) H2SqlDialect(org.apache.calcite.sql.dialect.H2SqlDialect) DerbySqlDialect(org.apache.calcite.sql.dialect.DerbySqlDialect) SybaseSqlDialect(org.apache.calcite.sql.dialect.SybaseSqlDialect) TeradataSqlDialect(org.apache.calcite.sql.dialect.TeradataSqlDialect) OracleSqlDialect(org.apache.calcite.sql.dialect.OracleSqlDialect) AccessSqlDialect(org.apache.calcite.sql.dialect.AccessSqlDialect) VerticaSqlDialect(org.apache.calcite.sql.dialect.VerticaSqlDialect) CalciteSqlDialect(org.apache.calcite.sql.dialect.CalciteSqlDialect) PhoenixSqlDialect(org.apache.calcite.sql.dialect.PhoenixSqlDialect) HsqldbSqlDialect(org.apache.calcite.sql.dialect.HsqldbSqlDialect) IngresSqlDialect(org.apache.calcite.sql.dialect.IngresSqlDialect) ParaccelSqlDialect(org.apache.calcite.sql.dialect.ParaccelSqlDialect) InterbaseSqlDialect(org.apache.calcite.sql.dialect.InterbaseSqlDialect) MssqlSqlDialect(org.apache.calcite.sql.dialect.MssqlSqlDialect) NetezzaSqlDialect(org.apache.calcite.sql.dialect.NetezzaSqlDialect) InfobrightSqlDialect(org.apache.calcite.sql.dialect.InfobrightSqlDialect) PostgresqlSqlDialect(org.apache.calcite.sql.dialect.PostgresqlSqlDialect) RedshiftSqlDialect(org.apache.calcite.sql.dialect.RedshiftSqlDialect) FirebirdSqlDialect(org.apache.calcite.sql.dialect.FirebirdSqlDialect) MysqlSqlDialect(org.apache.calcite.sql.dialect.MysqlSqlDialect) Db2SqlDialect(org.apache.calcite.sql.dialect.Db2SqlDialect) JethroDataSqlDialect(org.apache.calcite.sql.dialect.JethroDataSqlDialect) NeoviewSqlDialect(org.apache.calcite.sql.dialect.NeoviewSqlDialect) HiveSqlDialect(org.apache.calcite.sql.dialect.HiveSqlDialect) InformixSqlDialect(org.apache.calcite.sql.dialect.InformixSqlDialect) LucidDbSqlDialect(org.apache.calcite.sql.dialect.LucidDbSqlDialect) NullCollation(org.apache.calcite.config.NullCollation) DerbySqlDialect(org.apache.calcite.sql.dialect.DerbySqlDialect) PhoenixSqlDialect(org.apache.calcite.sql.dialect.PhoenixSqlDialect)

Aggregations

SQLException (java.sql.SQLException)1 NullCollation (org.apache.calcite.config.NullCollation)1 AccessSqlDialect (org.apache.calcite.sql.dialect.AccessSqlDialect)1 AnsiSqlDialect (org.apache.calcite.sql.dialect.AnsiSqlDialect)1 CalciteSqlDialect (org.apache.calcite.sql.dialect.CalciteSqlDialect)1 Db2SqlDialect (org.apache.calcite.sql.dialect.Db2SqlDialect)1 DerbySqlDialect (org.apache.calcite.sql.dialect.DerbySqlDialect)1 FirebirdSqlDialect (org.apache.calcite.sql.dialect.FirebirdSqlDialect)1 H2SqlDialect (org.apache.calcite.sql.dialect.H2SqlDialect)1 HiveSqlDialect (org.apache.calcite.sql.dialect.HiveSqlDialect)1 HsqldbSqlDialect (org.apache.calcite.sql.dialect.HsqldbSqlDialect)1 InfobrightSqlDialect (org.apache.calcite.sql.dialect.InfobrightSqlDialect)1 InformixSqlDialect (org.apache.calcite.sql.dialect.InformixSqlDialect)1 IngresSqlDialect (org.apache.calcite.sql.dialect.IngresSqlDialect)1 InterbaseSqlDialect (org.apache.calcite.sql.dialect.InterbaseSqlDialect)1 JethroDataSqlDialect (org.apache.calcite.sql.dialect.JethroDataSqlDialect)1 LucidDbSqlDialect (org.apache.calcite.sql.dialect.LucidDbSqlDialect)1 MssqlSqlDialect (org.apache.calcite.sql.dialect.MssqlSqlDialect)1 MysqlSqlDialect (org.apache.calcite.sql.dialect.MysqlSqlDialect)1 NeoviewSqlDialect (org.apache.calcite.sql.dialect.NeoviewSqlDialect)1