This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 17f123a Use SPI & OptimizerPropertiesBuilder to enhance
OptimizerContextFactory.props (#12601)
17f123a is described below
commit 17f123a73f9b16e63b1f5d296bdbae87ae0365d6
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Sep 20 23:52:56 2021 +0800
Use SPI & OptimizerPropertiesBuilder to enhance
OptimizerContextFactory.props (#12601)
* Add OptimizerPropertiesBuilder to enhance OptimizerContextFactory.props
* Add OptimizerPropertiesBuilder to enhance OptimizerContextFactory.props
---
.../optimize/context/OptimizerContextFactory.java | 79 +++-------------------
.../context/props/OptimizerPropertiesBuilder.java | 36 ++++++++++
.../props/OptimizerPropertiesBuilderFactory.java | 49 ++++++++++++++
.../props/impl/H2OptimizerPropertiesBuilder.java | 47 +++++++++++++
.../impl/MariaDBOptimizerPropertiesBuilder.java | 46 +++++++++++++
.../impl/MySQLOptimizerPropertiesBuilder.java | 51 ++++++++++++++
.../impl/OpenGaussOptimizerPropertiesBuilder.java | 46 +++++++++++++
.../impl/OracleOptimizerPropertiesBuilder.java | 46 +++++++++++++
.../impl/PostgreSQLOptimizerPropertiesBuilder.java | 46 +++++++++++++
.../impl/SQL92OptimizerPropertiesBuilder.java | 46 +++++++++++++
.../impl/SQLServerOptimizerPropertiesBuilder.java | 46 +++++++++++++
...timize.context.props.OptimizerPropertiesBuilder | 25 +++++++
12 files changed, 492 insertions(+), 71 deletions(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizerContextFactory.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizerContextFactory.java
index 5aaaad9..84e1391 100644
---
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizerContextFactory.java
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizerContextFactory.java
@@ -21,7 +21,6 @@ import lombok.Getter;
import org.apache.calcite.config.CalciteConnectionConfig;
import org.apache.calcite.config.CalciteConnectionConfigImpl;
import org.apache.calcite.config.CalciteConnectionProperty;
-import org.apache.calcite.config.Lex;
import org.apache.calcite.jdbc.CalciteSchema;
import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
import org.apache.calcite.plan.RelOptCluster;
@@ -32,27 +31,17 @@ import org.apache.calcite.prepare.CalciteCatalogReader;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.schema.Schema;
-import org.apache.calcite.sql.fun.SqlLibrary;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.calcite.sql.parser.SqlParser.Config;
import org.apache.calcite.sql.parser.impl.SqlParserImpl;
-import org.apache.calcite.sql.validate.SqlConformanceEnum;
import org.apache.calcite.sql.validate.SqlValidator;
import org.apache.calcite.sql.validate.SqlValidatorUtil;
import org.apache.calcite.sql2rel.SqlToRelConverter;
import org.apache.calcite.sql2rel.StandardConvertletTable;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
-import
org.apache.shardingsphere.infra.database.type.dialect.MariaDBDatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
-import
org.apache.shardingsphere.infra.database.type.dialect.OracleDatabaseType;
-import
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.SQL92DatabaseType;
-import
org.apache.shardingsphere.infra.database.type.dialect.SQLServerDatabaseType;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilderFactory;
import
org.apache.shardingsphere.infra.optimize.core.metadata.FederationMetaData;
import org.apache.shardingsphere.infra.optimize.core.plan.PlannerInitializer;
@@ -65,19 +54,11 @@ import java.util.Properties;
*/
public final class OptimizerContextFactory {
- private static final String LEX_CAMEL_NAME =
CalciteConnectionProperty.LEX.camelName();
-
- private static final String CONFORMANCE_CAMEL_NAME =
CalciteConnectionProperty.CONFORMANCE.camelName();
-
- private static final String FUN_CAMEL_NAME =
CalciteConnectionProperty.FUN.camelName();
-
- private static final String TIME_ZONE =
CalciteConnectionProperty.TIME_ZONE.camelName();
-
@Getter
private final DatabaseType databaseType;
@Getter
- private final Properties props = new Properties();
+ private final Properties props;
private final CalciteConnectionConfig connectionConfig;
@@ -97,7 +78,7 @@ public final class OptimizerContextFactory {
public OptimizerContextFactory(final Map<String, ShardingSphereMetaData>
metaDataMap) {
this.databaseType = metaDataMap.isEmpty() ? null :
metaDataMap.values().iterator().next().getResource().getDatabaseType();
- initProperties(databaseType);
+ props = createOptimizerProperties(databaseType);
typeFactory = new JavaTypeFactoryImpl();
cluster = newCluster();
metaData = new FederationMetaData(metaDataMap);
@@ -109,55 +90,11 @@ public final class OptimizerContextFactory {
.withParserFactory(SqlParserImpl.FACTORY);
}
- private void initProperties(final DatabaseType databaseType) {
- // TODO Logic could be improved.
- props.setProperty(TIME_ZONE, "UTC");
- if (databaseType instanceof MySQLDatabaseType || null == databaseType)
{
- props.setProperty(LEX_CAMEL_NAME, Lex.MYSQL.name());
- props.setProperty(CONFORMANCE_CAMEL_NAME,
SqlConformanceEnum.MYSQL_5.name());
- props.setProperty(FUN_CAMEL_NAME, SqlLibrary.MYSQL.fun);
- return;
- }
- if (databaseType instanceof H2DatabaseType) {
- // TODO No suitable type of Lex
- props.setProperty(LEX_CAMEL_NAME, Lex.MYSQL.name());
- props.setProperty(CONFORMANCE_CAMEL_NAME,
SqlConformanceEnum.LENIENT.name());
- props.setProperty(FUN_CAMEL_NAME, SqlLibrary.STANDARD.fun);
- return;
- }
- if (databaseType instanceof MariaDBDatabaseType) {
- props.setProperty(LEX_CAMEL_NAME, Lex.MYSQL.name());
- props.setProperty(CONFORMANCE_CAMEL_NAME,
SqlConformanceEnum.MYSQL_5.name());
- props.setProperty(FUN_CAMEL_NAME, SqlLibrary.MYSQL.fun);
- return;
- }
- if (databaseType instanceof OracleDatabaseType) {
- props.setProperty(LEX_CAMEL_NAME, Lex.ORACLE.name());
- props.setProperty(CONFORMANCE_CAMEL_NAME,
SqlConformanceEnum.ORACLE_12.name());
- props.setProperty(FUN_CAMEL_NAME, SqlLibrary.ORACLE.fun);
- return;
- }
- if (databaseType instanceof PostgreSQLDatabaseType || databaseType
instanceof OpenGaussDatabaseType) {
- // TODO No suitable type of Lex and conformance
- props.setProperty(LEX_CAMEL_NAME, Lex.JAVA.name());
- props.setProperty(CONFORMANCE_CAMEL_NAME,
SqlConformanceEnum.BABEL.name());
- props.setProperty(FUN_CAMEL_NAME, SqlLibrary.POSTGRESQL.fun);
- return;
- }
- if (databaseType instanceof SQL92DatabaseType) {
- // TODO No suitable type of Lex
- props.setProperty(LEX_CAMEL_NAME, Lex.MYSQL.name());
- props.setProperty(CONFORMANCE_CAMEL_NAME,
SqlConformanceEnum.STRICT_92.name());
- props.setProperty(FUN_CAMEL_NAME, SqlLibrary.STANDARD.fun);
- return;
- }
- if (databaseType instanceof SQLServerDatabaseType) {
- props.setProperty(LEX_CAMEL_NAME, Lex.SQL_SERVER.name());
- props.setProperty(CONFORMANCE_CAMEL_NAME,
SqlConformanceEnum.SQL_SERVER_2008.name());
- props.setProperty(FUN_CAMEL_NAME, SqlLibrary.STANDARD.fun);
- return;
- }
- throw new ShardingSphereException("No matching DatabaseType found");
+ private Properties createOptimizerProperties(final DatabaseType
databaseType) {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.TIME_ZONE.camelName(),
"UTC");
+ result.putAll(OptimizerPropertiesBuilderFactory.build(databaseType,
result));
+ return result;
}
private RelOptCluster newCluster() {
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/OptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/OptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..bb70738
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/OptimizerPropertiesBuilder.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props;
+
+import org.apache.shardingsphere.spi.required.RequiredSPI;
+import org.apache.shardingsphere.spi.typed.TypedSPI;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder.
+ */
+public interface OptimizerPropertiesBuilder extends TypedSPI, RequiredSPI {
+
+ /**
+ * Build optimizer properties.
+ *
+ * @return built optimizer properties
+ */
+ Properties build();
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/OptimizerPropertiesBuilderFactory.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/OptimizerPropertiesBuilderFactory.java
new file mode 100644
index 0000000..edb1189
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/OptimizerPropertiesBuilderFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props;
+
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.required.RequiredSPIRegistry;
+import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder factory.
+ */
+public final class OptimizerPropertiesBuilderFactory {
+
+ static {
+ ShardingSphereServiceLoader.register(OptimizerPropertiesBuilder.class);
+ }
+
+ /**
+ * Build optimizer properties.
+ *
+ * @param databaseType database type
+ * @param props properties to be built
+ * @return built optimizer properties
+ */
+ public static Properties build(final DatabaseType databaseType, final
Properties props) {
+ OptimizerPropertiesBuilder builder = null == databaseType
+ ?
RequiredSPIRegistry.getRegisteredService(OptimizerPropertiesBuilder.class)
+ :
TypedSPIRegistry.getRegisteredService(OptimizerPropertiesBuilder.class,
databaseType.getName(), props);
+ return builder.build();
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/H2OptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/H2OptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..7bfb576
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/H2OptimizerPropertiesBuilder.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for MySQL.
+ */
+public final class H2OptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ // TODO No suitable type of Lex
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.MYSQL.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.LENIENT.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.STANDARD.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "H2";
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/MariaDBOptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/MariaDBOptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..abf6be4
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/MariaDBOptimizerPropertiesBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for MariaDB.
+ */
+public final class MariaDBOptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.MYSQL.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.MYSQL_5.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.MYSQL.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "MariaDB";
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/MySQLOptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/MySQLOptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..ff80cf6
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/MySQLOptimizerPropertiesBuilder.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for MySQL.
+ */
+public final class MySQLOptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.MYSQL.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.MYSQL_5.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.MYSQL.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "MySQL";
+ }
+
+ @Override
+ public boolean isDefault() {
+ return true;
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/OpenGaussOptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/OpenGaussOptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..27715f1
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/OpenGaussOptimizerPropertiesBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for openGauss.
+ */
+public final class OpenGaussOptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.JAVA.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.BABEL.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.POSTGRESQL.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "openGauss";
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/OracleOptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/OracleOptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..f7661d4
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/OracleOptimizerPropertiesBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for Oracle.
+ */
+public final class OracleOptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.ORACLE.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.ORACLE_12.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.ORACLE.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "Oracle";
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/PostgreSQLOptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/PostgreSQLOptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..2fa6f8c
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/PostgreSQLOptimizerPropertiesBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for PostgreSQL.
+ */
+public final class PostgreSQLOptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.JAVA.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.BABEL.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.POSTGRESQL.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "PostgreSQL";
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/SQL92OptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/SQL92OptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..cdbf6f9
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/SQL92OptimizerPropertiesBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for SQL92.
+ */
+public final class SQL92OptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.MYSQL.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.STRICT_92.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.STANDARD.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "SQL92";
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/SQLServerOptimizerPropertiesBuilder.java
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/SQLServerOptimizerPropertiesBuilder.java
new file mode 100644
index 0000000..2bffab6
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/props/impl/SQLServerOptimizerPropertiesBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.optimize.context.props.impl;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.fun.SqlLibrary;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import
org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder;
+
+import java.util.Properties;
+
+/**
+ * Optimizer properties builder for SQLServer.
+ */
+public final class SQLServerOptimizerPropertiesBuilder implements
OptimizerPropertiesBuilder {
+
+ @Override
+ public Properties build() {
+ Properties result = new Properties();
+ result.setProperty(CalciteConnectionProperty.LEX.camelName(),
Lex.SQL_SERVER.name());
+ result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(),
SqlConformanceEnum.SQL_SERVER_2008.name());
+ result.setProperty(CalciteConnectionProperty.FUN.camelName(),
SqlLibrary.STANDARD.fun);
+ return result;
+ }
+
+ @Override
+ public String getType() {
+ return "SQLServer";
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder
new file mode 100644
index 0000000..d7925e0
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.optimize.context.props.OptimizerPropertiesBuilder
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.infra.optimize.context.props.impl.H2OptimizerPropertiesBuilder
+org.apache.shardingsphere.infra.optimize.context.props.impl.MySQLOptimizerPropertiesBuilder
+org.apache.shardingsphere.infra.optimize.context.props.impl.MariaDBOptimizerPropertiesBuilder
+org.apache.shardingsphere.infra.optimize.context.props.impl.PostgreSQLOptimizerPropertiesBuilder
+org.apache.shardingsphere.infra.optimize.context.props.impl.OpenGaussOptimizerPropertiesBuilder
+org.apache.shardingsphere.infra.optimize.context.props.impl.SQLServerOptimizerPropertiesBuilder
+org.apache.shardingsphere.infra.optimize.context.props.impl.OracleOptimizerPropertiesBuilder
+org.apache.shardingsphere.infra.optimize.context.props.impl.SQL92OptimizerPropertiesBuilder