use of org.apache.calcite.sql.dialect.HsqldbSqlDialect 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);
}
}
Aggregations