|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to you under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package org.apache.calcite.rel.rel2sql; |
| 18 | + |
| 19 | +import org.apache.calcite.config.NullCollation; |
| 20 | +import org.apache.calcite.sql.SqlDialect; |
| 21 | +import org.apache.calcite.sql.dialect.AnsiSqlDialect; |
| 22 | + |
| 23 | +import static org.apache.calcite.rel.rel2sql.DialectTestConfigs.JETHRO_DIALECT_SUPPLIER; |
| 24 | + |
| 25 | +/** Dialect code. */ |
| 26 | +enum DialectCode { |
| 27 | + ANSI(new AnsiSqlDialect(SqlDialect.EMPTY_CONTEXT)), |
| 28 | + BIG_QUERY(SqlDialect.DatabaseProduct.BIG_QUERY), |
| 29 | + CALCITE(SqlDialect.DatabaseProduct.CALCITE), |
| 30 | + CLICKHOUSE(SqlDialect.DatabaseProduct.CLICKHOUSE), |
| 31 | + DB2(SqlDialect.DatabaseProduct.DB2), |
| 32 | + EXASOL(SqlDialect.DatabaseProduct.EXASOL), |
| 33 | + FIREBOLT(SqlDialect.DatabaseProduct.FIREBOLT), |
| 34 | + HIVE(SqlDialect.DatabaseProduct.HIVE), |
| 35 | + HIVE_2_0(DialectTestConfigs.hiveDialect(2, 0)), |
| 36 | + HIVE_2_1(DialectTestConfigs.hiveDialect(2, 1)), |
| 37 | + HIVE_2_2(DialectTestConfigs.hiveDialect(2, 2)), |
| 38 | + HSQLDB(SqlDialect.DatabaseProduct.HSQLDB), |
| 39 | + INFORMIX(SqlDialect.DatabaseProduct.INFORMIX), |
| 40 | + JETHRO(JETHRO_DIALECT_SUPPLIER.get()), |
| 41 | + MOCK(new MockSqlDialect()), |
| 42 | + MSSQL_2008(DialectTestConfigs.mssqlDialect(10)), |
| 43 | + MSSQL_2012(DialectTestConfigs.mssqlDialect(11)), |
| 44 | + MSSQL_2017(DialectTestConfigs.mssqlDialect(14)), |
| 45 | + MYSQL(SqlDialect.DatabaseProduct.MYSQL), |
| 46 | + MYSQL_8(DialectTestConfigs.mysqlDialect(8, null)), |
| 47 | + MYSQL_FIRST(DialectTestConfigs.mysqlDialect(8, NullCollation.FIRST)), |
| 48 | + MYSQL_HIGH(DialectTestConfigs.mysqlDialect(8, NullCollation.HIGH)), |
| 49 | + MYSQL_LAST(DialectTestConfigs.mysqlDialect(8, NullCollation.LAST)), |
| 50 | + NON_ORDINAL(DialectTestConfigs.nonOrdinalDialect()), |
| 51 | + ORACLE(SqlDialect.DatabaseProduct.ORACLE), |
| 52 | + ORACLE_11(DialectTestConfigs.oracleDialect(11, null)), |
| 53 | + ORACLE_12(DialectTestConfigs.oracleDialect(12, null)), |
| 54 | + ORACLE_19(DialectTestConfigs.oracleDialect(19, null)), |
| 55 | + ORACLE_23(DialectTestConfigs.oracleDialect(23, null)), |
| 56 | + /** Oracle dialect with max length for varchar set to 512. */ |
| 57 | + ORACLE_MODIFIED(DialectTestConfigs.oracleDialect(12, 512)), |
| 58 | + POSTGRESQL(SqlDialect.DatabaseProduct.POSTGRESQL), |
| 59 | + /** Postgresql dialect with max length for varchar set to 256. */ |
| 60 | + POSTGRESQL_MODIFIED(DialectTestConfigs.postgresqlDialect(256, false)), |
| 61 | + /** Postgresql dialect with modified decimal type. */ |
| 62 | + POSTGRESQL_MODIFIED_DECIMAL( |
| 63 | + DialectTestConfigs.postgresqlDialect(null, true)), |
| 64 | + PRESTO(SqlDialect.DatabaseProduct.PRESTO), |
| 65 | + REDSHIFT(SqlDialect.DatabaseProduct.REDSHIFT), |
| 66 | + SNOWFLAKE(SqlDialect.DatabaseProduct.SNOWFLAKE), |
| 67 | + SPARK(SqlDialect.DatabaseProduct.SPARK), |
| 68 | + STARROCKS(SqlDialect.DatabaseProduct.STARROCKS), |
| 69 | + SYBASE(SqlDialect.DatabaseProduct.SYBASE), |
| 70 | + VERTICA(SqlDialect.DatabaseProduct.VERTICA); |
| 71 | + |
| 72 | + private final DialectTestConfig.Dialect dialect; |
| 73 | + |
| 74 | + DialectCode(SqlDialect.DatabaseProduct databaseProduct) { |
| 75 | + dialect = DialectTestConfig.Dialect.of(this, databaseProduct); |
| 76 | + } |
| 77 | + |
| 78 | + DialectCode(SqlDialect sqlDialect) { |
| 79 | + dialect = DialectTestConfig.Dialect.of(this, sqlDialect); |
| 80 | + } |
| 81 | + |
| 82 | + DialectTestConfig.Dialect toDialect() { |
| 83 | + return dialect; |
| 84 | + } |
| 85 | +} |
0 commit comments