You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/09/17 06:21:45 UTC

[shardingsphere] branch master updated: Optimize convert logic of concat function and mini refactor for segment convert (#21031)

This is an automated email from the ASF dual-hosted git repository.

yx9o 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 32b29ba72ee Optimize convert logic of concat function and mini refactor for segment convert (#21031)
32b29ba72ee is described below

commit 32b29ba72ee5ad0e618a804f4841daba69c067db
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Sat Sep 17 14:21:36 2022 +0800

    Optimize convert logic of concat function and mini refactor for segment convert (#21031)
---
 .../converter/context/ConverterContext.java        | 31 ------------
 .../converter/context/ConverterContextHolder.java  | 55 ----------------------
 .../segment/expression/ExpressionConverter.java    | 16 ++++---
 .../impl/BetweenExpressionConverter.java           | 14 ++----
 .../impl/BinaryOperationExpressionConverter.java   |  6 +--
 .../segment/expression/impl/ColumnConverter.java   |  7 +--
 .../impl/ExistsSubqueryExpressionConverter.java    | 15 ++----
 .../segment/expression/impl/FunctionConverter.java | 40 +++++-----------
 .../expression/impl/InExpressionConverter.java     |  6 +--
 .../converter/segment/from/TableConverter.java     |  4 +-
 .../segment/from/impl/JoinTableConverter.java      |  8 ++--
 .../segment/from/impl/SubqueryTableConverter.java  |  6 +--
 .../segment/groupby/GroupByConverter.java          |  2 +-
 .../converter/segment/groupby/HavingConverter.java |  4 +-
 .../segment/limit/PaginationValueSQLConverter.java |  5 +-
 .../segment/orderby/OrderByConverter.java          |  2 +-
 .../orderby/item/ColumnOrderByItemConverter.java   |  2 +-
 .../segment/projection/DistinctConverter.java      |  2 +-
 .../segment/projection/ProjectionsConverter.java   | 16 +++----
 .../impl/AggregationProjectionConverter.java       |  8 ++--
 .../projection/impl/ColumnProjectionConverter.java | 10 ++--
 .../DataTypeConverter.java}                        | 21 +++++----
 .../impl/ShorthandProjectionConverter.java         | 13 +++--
 .../statement/select/SelectStatementConverter.java | 12 ++---
 .../SQLNodeConvertEngineParameterizedTest.java     |  1 +
 25 files changed, 98 insertions(+), 208 deletions(-)

diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/context/ConverterContext.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/context/ConverterContext.java
deleted file mode 100644
index 62c85348526..00000000000
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/context/ConverterContext.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.sqlfederation.optimizer.converter.context;
-
-import lombok.Getter;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Converter context.
- */
-@Getter
-public final class ConverterContext {
-    
-    private final AtomicInteger parameterCount = new AtomicInteger();
-}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/context/ConverterContextHolder.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/context/ConverterContextHolder.java
deleted file mode 100644
index 59a0beb1a8c..00000000000
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/context/ConverterContextHolder.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.sqlfederation.optimizer.converter.context;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Hold convert context for current thread.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ConverterContextHolder {
-    
-    private static final ThreadLocal<ConverterContext> CONVERTER_CONTEXT = new ThreadLocal<>();
-    
-    /**
-     * Set convert context.
-     *
-     * @param converterContext convert context
-     */
-    public static void set(final ConverterContext converterContext) {
-        CONVERTER_CONTEXT.set(converterContext);
-    }
-    
-    /**
-     * Get convert context.
-     *
-     * @return convert context
-     */
-    public static ConverterContext get() {
-        return CONVERTER_CONTEXT.get();
-    }
-    
-    /**
-     * Remove convert context.
-     */
-    public static void remove() {
-        CONVERTER_CONTEXT.remove();
-    }
-}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java
index a149f545e3a..e11acebfeb1 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java
@@ -32,6 +32,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.L
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.subquery.SubqueryExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.AggregationProjectionSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeSegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.BetweenExpressionConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.BinaryOperationExpressionConverter;
@@ -44,6 +45,7 @@ import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expre
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ParameterMarkerExpressionConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.SubqueryExpressionConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.AggregationProjectionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.DataTypeConverter;
 
 import java.util.Optional;
 
@@ -65,23 +67,25 @@ public final class ExpressionConverter implements SQLSegmentConverter<Expression
         } else if (segment instanceof ListExpression) {
             return new ListExpressionConverter().convert((ListExpression) segment);
         } else if (segment instanceof BinaryOperationExpression) {
-            return new BinaryOperationExpressionConverter().convert((BinaryOperationExpression) segment).map(optional -> optional);
+            return new BinaryOperationExpressionConverter().convert((BinaryOperationExpression) segment);
         } else if (segment instanceof ColumnSegment) {
-            return new ColumnConverter().convert((ColumnSegment) segment).map(optional -> optional);
+            return new ColumnConverter().convert((ColumnSegment) segment);
         } else if (segment instanceof ExistsSubqueryExpression) {
-            return new ExistsSubqueryExpressionConverter().convert((ExistsSubqueryExpression) segment).map(optional -> optional);
+            return new ExistsSubqueryExpressionConverter().convert((ExistsSubqueryExpression) segment);
         } else if (segment instanceof SubqueryExpressionSegment) {
             return new SubqueryExpressionConverter().convert((SubqueryExpressionSegment) segment);
         } else if (segment instanceof InExpression) {
-            return new InExpressionConverter().convert((InExpression) segment).map(optional -> optional);
+            return new InExpressionConverter().convert((InExpression) segment);
         } else if (segment instanceof BetweenExpression) {
-            return new BetweenExpressionConverter().convert((BetweenExpression) segment).map(optional -> optional);
+            return new BetweenExpressionConverter().convert((BetweenExpression) segment);
         } else if (segment instanceof ParameterMarkerExpressionSegment) {
             return new ParameterMarkerExpressionConverter().convert((ParameterMarkerExpressionSegment) segment);
         } else if (segment instanceof FunctionSegment) {
             return new FunctionConverter().convert((FunctionSegment) segment);
         } else if (segment instanceof AggregationProjectionSegment) {
-            return new AggregationProjectionConverter().convert((AggregationProjectionSegment) segment).map(optional -> optional);
+            return new AggregationProjectionConverter().convert((AggregationProjectionSegment) segment);
+        } else if (segment instanceof DataTypeSegment) {
+            return new DataTypeConverter().convert((DataTypeSegment) segment);
         }
         throw new UnsupportedSQLOperationException("unsupported TableSegment type: " + segment.getClass());
     }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BetweenExpressionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BetweenExpressionConverter.java
index 99d1de7bb59..de477412cc2 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BetweenExpressionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BetweenExpressionConverter.java
@@ -17,14 +17,13 @@
 
 package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl;
 
-import lombok.RequiredArgsConstructor;
 import org.apache.calcite.sql.SqlBasicCall;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BetweenExpression;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BetweenExpression;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -35,17 +34,10 @@ import java.util.Optional;
 /**
  * Between expression converter.
  */
-@RequiredArgsConstructor
-public final class BetweenExpressionConverter implements SQLSegmentConverter<BetweenExpression, SqlBasicCall> {
-    
-    private final boolean not;
-    
-    public BetweenExpressionConverter() {
-        not = false;
-    }
+public final class BetweenExpressionConverter implements SQLSegmentConverter<BetweenExpression, SqlNode> {
     
     @Override
-    public Optional<SqlBasicCall> convert(final BetweenExpression expression) {
+    public Optional<SqlNode> convert(final BetweenExpression expression) {
         if (null == expression) {
             return Optional.empty();
         }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BinaryOperationExpressionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BinaryOperationExpressionConverter.java
index 45e37153a32..ff9dd8f1aab 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BinaryOperationExpressionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/BinaryOperationExpressionConverter.java
@@ -24,9 +24,9 @@ import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.SqlOperator;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
 
 import java.util.Collections;
 import java.util.LinkedList;
@@ -38,7 +38,7 @@ import java.util.TreeMap;
 /**
  * Binary operation expression converter.
  */
-public final class BinaryOperationExpressionConverter implements SQLSegmentConverter<BinaryOperationExpression, SqlBasicCall> {
+public final class BinaryOperationExpressionConverter implements SQLSegmentConverter<BinaryOperationExpression, SqlNode> {
     
     private static final Map<String, SqlOperator> REGISTRY = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
     
@@ -72,7 +72,7 @@ public final class BinaryOperationExpressionConverter implements SQLSegmentConve
     }
     
     @Override
-    public Optional<SqlBasicCall> convert(final BinaryOperationExpression segment) {
+    public Optional<SqlNode> convert(final BinaryOperationExpression segment) {
         SqlOperator operator = convertOperator(segment.getOperator());
         List<SqlNode> sqlNodes = convertSqlNodes(segment);
         return Optional.of(new SqlBasicCall(operator, sqlNodes, SqlParserPos.ZERO));
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ColumnConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ColumnConverter.java
index a36d5cb611d..3fb8cc70fea 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ColumnConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ColumnConverter.java
@@ -18,10 +18,11 @@
 package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl;
 
 import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 
 import java.util.Arrays;
 import java.util.Optional;
@@ -29,10 +30,10 @@ import java.util.Optional;
 /**
  * Column converter.
  */
-public final class ColumnConverter implements SQLSegmentConverter<ColumnSegment, SqlIdentifier> {
+public final class ColumnConverter implements SQLSegmentConverter<ColumnSegment, SqlNode> {
     
     @Override
-    public Optional<SqlIdentifier> convert(final ColumnSegment segment) {
+    public Optional<SqlNode> convert(final ColumnSegment segment) {
         Optional<OwnerSegment> owner = segment.getOwner();
         String columnName = segment.getIdentifier().getValue();
         SqlIdentifier sqlIdentifier = owner.map(optional -> new SqlIdentifier(Arrays.asList(optional.getIdentifier().getValue(), columnName), SqlParserPos.ZERO))
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ExistsSubqueryExpressionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ExistsSubqueryExpressionConverter.java
index 10885029578..cfd128ebc55 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ExistsSubqueryExpressionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/ExistsSubqueryExpressionConverter.java
@@ -17,13 +17,13 @@
 
 package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl;
 
-import lombok.RequiredArgsConstructor;
 import org.apache.calcite.sql.SqlBasicCall;
+import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExistsSubqueryExpression;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.statement.select.SelectStatementConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExistsSubqueryExpression;
 
 import java.util.Collections;
 import java.util.Optional;
@@ -31,17 +31,10 @@ import java.util.Optional;
 /**
  * Exists subquery expression converter.
  */
-@RequiredArgsConstructor
-public final class ExistsSubqueryExpressionConverter implements SQLSegmentConverter<ExistsSubqueryExpression, SqlBasicCall> {
-    
-    private final boolean not;
-    
-    public ExistsSubqueryExpressionConverter() {
-        not = false;
-    }
+public final class ExistsSubqueryExpressionConverter implements SQLSegmentConverter<ExistsSubqueryExpression, SqlNode> {
     
     @Override
-    public Optional<SqlBasicCall> convert(final ExistsSubqueryExpression expression) {
+    public Optional<SqlNode> convert(final ExistsSubqueryExpression expression) {
         if (null == expression) {
             return Optional.empty();
         }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/FunctionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/FunctionConverter.java
index f2c16b4c3c2..6419d8ead75 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/FunctionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/FunctionConverter.java
@@ -18,26 +18,20 @@
 package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl;
 
 import org.apache.calcite.sql.SqlBasicCall;
-import org.apache.calcite.sql.SqlDataTypeSpec;
-import org.apache.calcite.sql.SqlDynamicParam;
 import org.apache.calcite.sql.SqlFunctionCategory;
 import org.apache.calcite.sql.SqlIdentifier;
-import org.apache.calcite.sql.SqlLiteral;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlUnresolvedFunction;
-import org.apache.calcite.sql.SqlUserDefinedTypeNameSpec;
 import org.apache.calcite.sql.fun.SqlCastFunction;
 import org.apache.calcite.sql.fun.SqlPositionFunction;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.FunctionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
 
-import java.util.ArrayList;
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Optional;
 
@@ -49,18 +43,18 @@ public final class FunctionConverter implements SQLSegmentConverter<FunctionSegm
     @Override
     public Optional<SqlNode> convert(final FunctionSegment segment) {
         if ("POSITION".equalsIgnoreCase(segment.getFunctionName())) {
-            return Optional.of(new SqlBasicCall(new SqlPositionFunction(), getSqlNodes(segment.getParameters()), SqlParserPos.ZERO));
+            return Optional.of(new SqlBasicCall(new SqlPositionFunction(), getFunctionParameters(segment.getParameters()), SqlParserPos.ZERO));
         }
         if ("CAST".equalsIgnoreCase(segment.getFunctionName())) {
-            return Optional.of(new SqlBasicCall(new SqlCastFunction(), getSqlNodes(segment.getParameters()), SqlParserPos.ZERO));
+            return Optional.of(new SqlBasicCall(new SqlCastFunction(), getFunctionParameters(segment.getParameters()), SqlParserPos.ZERO));
         }
         if ("CONCAT".equalsIgnoreCase(segment.getFunctionName())) {
             return Optional.of(new SqlBasicCall(new SqlUnresolvedFunction(new SqlIdentifier(segment.getFunctionName(), SqlParserPos.ZERO),
-                    null, null, null, null, SqlFunctionCategory.USER_DEFINED_FUNCTION), getSqlNodes(segment.getParameters()), SqlParserPos.ZERO));
+                    null, null, null, null, SqlFunctionCategory.USER_DEFINED_FUNCTION), getFunctionParameters(segment.getParameters()), SqlParserPos.ZERO));
         }
         if ("DATABASE".equalsIgnoreCase(segment.getFunctionName())) {
             return Optional.of(new SqlBasicCall(new SqlUnresolvedFunction(new SqlIdentifier(segment.getFunctionName(), SqlParserPos.ZERO),
-                    null, null, null, null, SqlFunctionCategory.USER_DEFINED_FUNCTION), getSqlNodes(segment.getParameters()), SqlParserPos.ZERO));
+                    null, null, null, null, SqlFunctionCategory.USER_DEFINED_FUNCTION), getFunctionParameters(segment.getParameters()), SqlParserPos.ZERO));
         }
         if ("CURRENT_USER".equalsIgnoreCase(segment.getFunctionName())) {
             return Optional.of(new SqlIdentifier(segment.getFunctionName(), SqlParserPos.ZERO));
@@ -68,19 +62,11 @@ public final class FunctionConverter implements SQLSegmentConverter<FunctionSegm
         return Optional.empty();
     }
     
-    private List<SqlNode> getSqlNodes(final Collection<ExpressionSegment> sqlSegments) {
-        List<SqlNode> sqlNodes = new ArrayList<>();
-        sqlSegments.forEach(each -> {
-            if (each instanceof LiteralExpressionSegment) {
-                sqlNodes.add(SqlLiteral.createCharString(((LiteralExpressionSegment) each).getLiterals().toString(), SqlParserPos.ZERO));
-            }
-            if (each instanceof DataTypeSegment) {
-                sqlNodes.add(new SqlDataTypeSpec(new SqlUserDefinedTypeNameSpec(((DataTypeSegment) each).getDataTypeName(), SqlParserPos.ZERO), SqlParserPos.ZERO));
-            }
-            if (each instanceof ParameterMarkerExpressionSegment) {
-                sqlNodes.add(new SqlDynamicParam(((ParameterMarkerExpressionSegment) each).getParameterMarkerIndex(), SqlParserPos.ZERO));
-            }
-        });
-        return new ArrayList<>(sqlNodes);
+    private List<SqlNode> getFunctionParameters(final Collection<ExpressionSegment> sqlSegments) {
+        List<SqlNode> result = new LinkedList<>();
+        for (ExpressionSegment each : sqlSegments) {
+            new ExpressionConverter().convert(each).ifPresent(result::add);
+        }
+        return result;
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/InExpressionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/InExpressionConverter.java
index 2d8e2c0cae9..15fdd1a59ee 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/InExpressionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/InExpressionConverter.java
@@ -22,9 +22,9 @@ import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.InExpression;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.InExpression;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -35,10 +35,10 @@ import java.util.Optional;
 /**
  * In expression converter.
  */
-public final class InExpressionConverter implements SQLSegmentConverter<InExpression, SqlBasicCall> {
+public final class InExpressionConverter implements SQLSegmentConverter<InExpression, SqlNode> {
     
     @Override
-    public Optional<SqlBasicCall> convert(final InExpression expression) {
+    public Optional<SqlNode> convert(final InExpression expression) {
         if (null == expression) {
             return Optional.empty();
         }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java
index 243a070d99f..f58ae2ec3d7 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java
@@ -43,9 +43,9 @@ public final class TableConverter implements SQLSegmentConverter<TableSegment, S
         if (segment instanceof SimpleTableSegment) {
             return new SimpleTableConverter().convert((SimpleTableSegment) segment);
         } else if (segment instanceof JoinTableSegment) {
-            return new JoinTableConverter().convert((JoinTableSegment) segment).map(optional -> optional);
+            return new JoinTableConverter().convert((JoinTableSegment) segment);
         } else if (segment instanceof SubqueryTableSegment) {
-            return new SubqueryTableConverter().convert((SubqueryTableSegment) segment).map(optional -> optional);
+            return new SubqueryTableConverter().convert((SubqueryTableSegment) segment);
         }
         throw new UnsupportedSQLOperationException("Unsupported segment type: " + segment.getClass());
     }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/JoinTableConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/JoinTableConverter.java
index 59a56fc2271..a0b3f3439af 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/JoinTableConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/JoinTableConverter.java
@@ -24,12 +24,12 @@ import org.apache.calcite.sql.SqlLiteral;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.JoinTableSegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ColumnConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.TableConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.JoinTableSegment;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -38,10 +38,10 @@ import java.util.Optional;
 /**
  * Join converter.
  */
-public final class JoinTableConverter implements SQLSegmentConverter<JoinTableSegment, SqlJoin> {
+public final class JoinTableConverter implements SQLSegmentConverter<JoinTableSegment, SqlNode> {
     
     @Override
-    public Optional<SqlJoin> convert(final JoinTableSegment segment) {
+    public Optional<SqlNode> convert(final JoinTableSegment segment) {
         SqlNode left = new TableConverter().convert(segment.getLeft()).orElseThrow(IllegalStateException::new);
         SqlNode right = new TableConverter().convert(segment.getRight()).orElseThrow(IllegalStateException::new);
         Optional<SqlNode> condition = convertJoinCondition(segment);
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SubqueryTableConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SubqueryTableConverter.java
index 2f2f47946c7..a779a4ea5e0 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SubqueryTableConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/impl/SubqueryTableConverter.java
@@ -22,9 +22,9 @@ import org.apache.calcite.sql.SqlIdentifier;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SubqueryTableSegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.statement.select.SelectStatementConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SubqueryTableSegment;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -34,10 +34,10 @@ import java.util.Optional;
 /**
  * Subquery table converter.
  */
-public final class SubqueryTableConverter implements SQLSegmentConverter<SubqueryTableSegment, SqlBasicCall> {
+public final class SubqueryTableConverter implements SQLSegmentConverter<SubqueryTableSegment, SqlNode> {
     
     @Override
-    public Optional<SqlBasicCall> convert(final SubqueryTableSegment segment) {
+    public Optional<SqlNode> convert(final SubqueryTableSegment segment) {
         if (null == segment) {
             return Optional.empty();
         }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/GroupByConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/GroupByConverter.java
index 98b4733637a..10f7b4ed48a 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/GroupByConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/GroupByConverter.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.grou
 
 import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.GroupBySegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.orderby.item.OrderByItemConverterUtil;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.GroupBySegment;
 
 import java.util.Optional;
 
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/HavingConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/HavingConverter.java
index ce1778bdfeb..a762bd450ae 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/HavingConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/groupby/HavingConverter.java
@@ -18,9 +18,9 @@
 package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.groupby;
 
 import org.apache.calcite.sql.SqlNode;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.HavingSegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.HavingSegment;
 
 import java.util.Optional;
 
@@ -29,8 +29,6 @@ import java.util.Optional;
  */
 public final class HavingConverter implements SQLSegmentConverter<HavingSegment, SqlNode> {
     
-    private static final int HAVING_SEGMENT_LENGTH = 7;
-    
     @Override
     public Optional<SqlNode> convert(final HavingSegment segment) {
         return null == segment ? Optional.empty() : new ExpressionConverter().convert(segment.getExpr());
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/limit/PaginationValueSQLConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/limit/PaginationValueSQLConverter.java
index 3837d637cd8..8bc54e6de05 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/limit/PaginationValueSQLConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/limit/PaginationValueSQLConverter.java
@@ -22,11 +22,10 @@ import org.apache.calcite.sql.SqlDynamicParam;
 import org.apache.calcite.sql.SqlLiteral;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.context.ConverterContext;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.NumberLiteralPaginationValueSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.PaginationValueSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.ParameterMarkerLimitValueSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 
 import java.util.Optional;
 
@@ -36,8 +35,6 @@ import java.util.Optional;
 @RequiredArgsConstructor
 public final class PaginationValueSQLConverter implements SQLSegmentConverter<PaginationValueSegment, SqlNode> {
     
-    private final ConverterContext context;
-    
     @Override
     public Optional<SqlNode> convert(final PaginationValueSegment segment) {
         return Optional.of(segment instanceof NumberLiteralPaginationValueSegment
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/OrderByConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/OrderByConverter.java
index 41d5fbdf607..5e530e0ce8a 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/OrderByConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/OrderByConverter.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.orde
 
 import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.OrderBySegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.orderby.item.OrderByItemConverterUtil;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.OrderBySegment;
 
 import java.util.Optional;
 
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/ColumnOrderByItemConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/ColumnOrderByItemConverter.java
index f663b4cd5dc..dc132e3c1d5 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/ColumnOrderByItemConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/ColumnOrderByItemConverter.java
@@ -37,7 +37,7 @@ public final class ColumnOrderByItemConverter implements SQLSegmentConverter<Col
     
     @Override
     public Optional<SqlNode> convert(final ColumnOrderByItemSegment segment) {
-        Optional<SqlNode> result = new ColumnConverter().convert(segment.getColumn()).map(optional -> optional);
+        Optional<SqlNode> result = new ColumnConverter().convert(segment.getColumn());
         if (result.isPresent() && Objects.equals(OrderDirection.DESC, segment.getOrderDirection())) {
             result = Optional.of(new SqlBasicCall(SqlStdOperatorTable.DESC, Collections.singletonList(result.get()), SqlParserPos.ZERO));
         }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/DistinctConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/DistinctConverter.java
index ad43e44a797..633a845c644 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/DistinctConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/DistinctConverter.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.proj
 import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.SqlSelectKeyword;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 
 import java.util.Collections;
 import java.util.Optional;
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/ProjectionsConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/ProjectionsConverter.java
index 5e68db9c199..5c54fb2ffcc 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/ProjectionsConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/ProjectionsConverter.java
@@ -20,12 +20,6 @@ package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.proj
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.AggregationProjectionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.ColumnProjectionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.ExpressionProjectionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.ShorthandProjectionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.SubqueryProjectionConverter;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.AggregationProjectionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ColumnProjectionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ExpressionProjectionSegment;
@@ -33,6 +27,12 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.Projecti
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ShorthandProjectionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.SubqueryProjectionSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.AggregationProjectionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.ColumnProjectionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.ExpressionProjectionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.ShorthandProjectionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.SubqueryProjectionConverter;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -58,11 +58,11 @@ public final class ProjectionsConverter implements SQLSegmentConverter<Projectio
         } else if (segment instanceof ExpressionProjectionSegment) {
             return new ExpressionProjectionConverter().convert((ExpressionProjectionSegment) segment);
         } else if (segment instanceof ShorthandProjectionSegment) {
-            return new ShorthandProjectionConverter().convert((ShorthandProjectionSegment) segment).map(optional -> optional);
+            return new ShorthandProjectionConverter().convert((ShorthandProjectionSegment) segment);
         } else if (segment instanceof SubqueryProjectionSegment) {
             return new SubqueryProjectionConverter().convert((SubqueryProjectionSegment) segment);
         } else if (segment instanceof AggregationProjectionSegment) {
-            return new AggregationProjectionConverter().convert((AggregationProjectionSegment) segment).map(optional -> optional);
+            return new AggregationProjectionConverter().convert((AggregationProjectionSegment) segment);
         }
         // TODO process other projection
         return Optional.empty();
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java
index 3ea4d7b5971..f5094504aa5 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/AggregationProjectionConverter.java
@@ -26,11 +26,11 @@ import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlSelectKeyword;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.AggregationDistinctProjectionSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.AggregationProjectionSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.ExpressionConverter;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -44,7 +44,7 @@ import java.util.TreeMap;
 /**
  * Aggregation projection converter. 
  */
-public final class AggregationProjectionConverter implements SQLSegmentConverter<AggregationProjectionSegment, SqlBasicCall> {
+public final class AggregationProjectionConverter implements SQLSegmentConverter<AggregationProjectionSegment, SqlNode> {
     
     private static final Map<String, SqlAggFunction> REGISTRY = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
     
@@ -62,7 +62,7 @@ public final class AggregationProjectionConverter implements SQLSegmentConverter
     }
     
     @Override
-    public Optional<SqlBasicCall> convert(final AggregationProjectionSegment segment) {
+    public Optional<SqlNode> convert(final AggregationProjectionSegment segment) {
         if (null == segment) {
             return Optional.empty();
         }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ColumnProjectionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ColumnProjectionConverter.java
index 156dd29407e..11f533de1cb 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ColumnProjectionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ColumnProjectionConverter.java
@@ -22,9 +22,9 @@ import org.apache.calcite.sql.SqlBasicCall;
 import org.apache.calcite.sql.SqlIdentifier;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ColumnProjectionSegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ColumnConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ColumnProjectionSegment;
 
 import java.util.Arrays;
 import java.util.Optional;
@@ -37,10 +37,10 @@ public final class ColumnProjectionConverter implements SQLSegmentConverter<Colu
     @Override
     public Optional<SqlNode> convert(final ColumnProjectionSegment segment) {
         if (segment.getAlias().isPresent()) {
-            Optional<SqlIdentifier> columnSqlIdentifier = new ColumnConverter().convert(segment.getColumn());
-            SqlIdentifier aliasSqlIdentifier = new SqlIdentifier(segment.getAlias().get(), SqlParserPos.ZERO);
-            return Optional.of(new SqlBasicCall(new SqlAsOperator(), Arrays.asList(columnSqlIdentifier.get(), aliasSqlIdentifier), SqlParserPos.ZERO));
+            Optional<SqlNode> column = new ColumnConverter().convert(segment.getColumn());
+            SqlIdentifier alias = new SqlIdentifier(segment.getAlias().get(), SqlParserPos.ZERO);
+            return column.map(optional -> new SqlBasicCall(new SqlAsOperator(), Arrays.asList(optional, alias), SqlParserPos.ZERO));
         }
-        return new ColumnConverter().convert(segment.getColumn()).map(optional -> optional);
+        return new ColumnConverter().convert(segment.getColumn());
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/DistinctConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/DataTypeConverter.java
similarity index 61%
copy from shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/DistinctConverter.java
copy to shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/DataTypeConverter.java
index ad43e44a797..2d5c4c4f24e 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/DistinctConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/DataTypeConverter.java
@@ -15,24 +15,27 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection;
+package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl;
 
-import org.apache.calcite.sql.SqlNodeList;
-import org.apache.calcite.sql.SqlSelectKeyword;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlUserDefinedTypeNameSpec;
 import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DataTypeSegment;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
 
-import java.util.Collections;
 import java.util.Optional;
 
 /**
- * Distinct converter.
+ * Data type converter. 
  */
-public final class DistinctConverter implements SQLSegmentConverter<ProjectionsSegment, SqlNodeList> {
+public final class DataTypeConverter implements SQLSegmentConverter<DataTypeSegment, SqlNode> {
     
     @Override
-    public Optional<SqlNodeList> convert(final ProjectionsSegment segment) {
-        return segment.isDistinctRow() ? Optional.of(new SqlNodeList(Collections.singletonList(SqlSelectKeyword.DISTINCT.symbol(SqlParserPos.ZERO)), SqlParserPos.ZERO)) : Optional.empty();
+    public Optional<SqlNode> convert(final DataTypeSegment segment) {
+        if (null == segment) {
+            return Optional.empty();
+        }
+        return Optional.of(new SqlDataTypeSpec(new SqlUserDefinedTypeNameSpec(segment.getDataTypeName(), SqlParserPos.ZERO), SqlParserPos.ZERO));
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ShorthandProjectionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ShorthandProjectionConverter.java
index 70604abe3ea..43ab10fbb3e 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ShorthandProjectionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/ShorthandProjectionConverter.java
@@ -19,9 +19,10 @@ package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.proj
 
 import com.google.common.collect.ImmutableList;
 import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ShorthandProjectionSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 
 import java.util.Arrays;
 import java.util.Optional;
@@ -29,14 +30,16 @@ import java.util.Optional;
 /**
  * Shorthand projection converter. 
  */
-public final class ShorthandProjectionConverter implements SQLSegmentConverter<ShorthandProjectionSegment, SqlIdentifier> {
+public final class ShorthandProjectionConverter implements SQLSegmentConverter<ShorthandProjectionSegment, SqlNode> {
     
     @Override
-    public Optional<SqlIdentifier> convert(final ShorthandProjectionSegment segment) {
+    public Optional<SqlNode> convert(final ShorthandProjectionSegment segment) {
         if (null == segment) {
             return Optional.empty();
         }
-        return segment.getOwner().map(optional -> Optional.of(SqlIdentifier.star(Arrays.asList(optional.getIdentifier().getValue(), ""),
-                SqlParserPos.ZERO, ImmutableList.of(SqlParserPos.ZERO)))).orElseGet(() -> Optional.of(SqlIdentifier.star(SqlParserPos.ZERO)));
+        if (!segment.getOwner().isPresent()) {
+            return Optional.of(SqlIdentifier.star(SqlParserPos.ZERO));
+        }
+        return Optional.of(SqlIdentifier.star(Arrays.asList(segment.getOwner().get().getIdentifier().getValue(), ""), SqlParserPos.ZERO, ImmutableList.of(SqlParserPos.ZERO)));
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/statement/select/SelectStatementConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/statement/select/SelectStatementConverter.java
index 6265562331a..eb8d71cdee5 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/statement/select/SelectStatementConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/statement/select/SelectStatementConverter.java
@@ -22,7 +22,9 @@ import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.SqlOrderBy;
 import org.apache.calcite.sql.SqlSelect;
 import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.context.ConverterContext;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.LimitSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml.SelectStatementHandler;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.TableConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.groupby.GroupByConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.groupby.HavingConverter;
@@ -32,9 +34,6 @@ import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.proje
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.ProjectionsConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.where.WhereConverter;
 import org.apache.shardingsphere.sqlfederation.optimizer.converter.statement.SQLStatementConverter;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.LimitSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.handler.dml.SelectStatementHandler;
 
 import java.util.Optional;
 
@@ -53,11 +52,10 @@ public final class SelectStatementConverter implements SQLStatementConverter<Sel
         SqlNode having = selectStatement.getHaving().flatMap(optional -> new HavingConverter().convert(optional)).orElse(null);
         SqlNodeList orderBy = selectStatement.getOrderBy().flatMap(optional -> new OrderByConverter().convert(optional)).orElse(SqlNodeList.EMPTY);
         Optional<LimitSegment> limit = SelectStatementHandler.getLimitSegment(selectStatement);
-        ConverterContext context = new ConverterContext();
         SqlSelect sqlSelect = new SqlSelect(SqlParserPos.ZERO, distinct, projection, from, where, groupBy, having, SqlNodeList.EMPTY, null, null, null, SqlNodeList.EMPTY);
         if (limit.isPresent()) {
-            SqlNode offset = limit.get().getOffset().flatMap(optional -> new PaginationValueSQLConverter(context).convert(optional)).orElse(null);
-            SqlNode rowCount = limit.get().getRowCount().flatMap(optional -> new PaginationValueSQLConverter(context).convert(optional)).orElse(null);
+            SqlNode offset = limit.get().getOffset().flatMap(optional -> new PaginationValueSQLConverter().convert(optional)).orElse(null);
+            SqlNode rowCount = limit.get().getRowCount().flatMap(optional -> new PaginationValueSQLConverter().convert(optional)).orElse(null);
             return new SqlOrderBy(SqlParserPos.ZERO, sqlSelect, orderBy, offset, rowCount);
         }
         return !orderBy.isEmpty() ? new SqlOrderBy(SqlParserPos.ZERO, sqlSelect, orderBy, null, null) : sqlSelect;
diff --git a/shardingsphere-test/shardingsphere-optimize-test/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConvertEngineParameterizedTest.java b/shardingsphere-test/shardingsphere-optimize-test/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConvertEngineParameterizedTest.java
index cb0c6e85795..56fbcf1b19a 100644
--- a/shardingsphere-test/shardingsphere-optimize-test/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConvertEngineParameterizedTest.java
+++ b/shardingsphere-test/shardingsphere-optimize-test/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConvertEngineParameterizedTest.java
@@ -105,6 +105,7 @@ public final class SQLNodeConvertEngineParameterizedTest {
         SUPPORTED_SQL_CASE_IDS.add("select_database");
         SUPPORTED_SQL_CASE_IDS.add("select_distinct_with_count_calculation");
         SUPPORTED_SQL_CASE_IDS.add("select_count_like_escape");
+        SUPPORTED_SQL_CASE_IDS.add("select_with_projection_subquery_and_multiple_parameters");
     }
     
     private final String sqlCaseId;