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

zhaojinchao 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 e5df54d52ce Modify getColumnName and getColumnLabel logic for 
ColumnProjection (#27421)
e5df54d52ce is described below

commit e5df54d52cec64898e7082735bbbed5fb990a19c
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Mon Jul 24 17:46:37 2023 +0800

    Modify getColumnName and getColumnLabel logic for ColumnProjection (#27421)
---
 .../encrypt/merge/dql/EncryptMergedResult.java     |  2 +-
 .../encrypt/rewrite/aware/DatabaseTypeAware.java   | 33 ++++++++++++
 .../parameter/EncryptParameterRewriterBuilder.java |  6 ++-
 .../EncryptCreateTableTokenGenerator.java          |  8 ++-
 .../EncryptIndexColumnTokenGenerator.java          | 10 ++--
 .../EncryptOrderByItemTokenGenerator.java          | 10 ++--
 .../EncryptPredicateColumnTokenGenerator.java      | 10 ++--
 .../generator/EncryptProjectionTokenGenerator.java | 24 +++++----
 .../EncryptInsertCipherNameTokenGenerator.java     |  3 +-
 .../EncryptProjectionTokenGeneratorTest.java       |  6 +--
 .../mask/merge/dql/MaskAlgorithmMetaDataTest.java  |  4 +-
 .../select/projection/engine/ProjectionEngine.java | 10 ++--
 .../projection/impl/AggregationProjection.java     |  5 --
 .../select/projection/impl/ColumnProjection.java   | 12 +++--
 .../select/projection/util/ProjectionUtils.java    | 27 +++++++---
 .../RowNumberPaginationContextEngineTest.java      | 12 +++--
 .../select/projection/ProjectionsContextTest.java  | 10 ++--
 .../projection/engine/ProjectionEngineTest.java    | 60 +++++++++++-----------
 .../projection/impl/AggregationProjectionTest.java | 21 ++++----
 .../binder/segment/table/TablesContextTest.java    | 10 ++--
 .../generic/SubstitutableColumnNameTokenTest.java  | 13 ++---
 .../ShardingSphereResultSetUtilsTest.java          |  5 +-
 .../resultset/SQLFederationResultSetMetaData.java  |  4 +-
 .../resultset/SQLFederationResultSetTest.java      |  6 ++-
 24 files changed, 198 insertions(+), 113 deletions(-)

diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
index d4b231aeff6..22d4a62e69e 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
@@ -63,7 +63,7 @@ public final class EncryptMergedResult implements 
MergedResult {
         TablesContext tablesContext = 
selectStatementContext.getTablesContext();
         String schemaName = tablesContext.getSchemaName()
                 .orElseGet(() -> 
DatabaseTypeEngine.getDefaultSchemaName(selectStatementContext.getDatabaseType(),
 database.getName()));
-        ColumnProjection originalColumn = new 
ColumnProjection(columnProjection.get().getOriginalOwner(), 
columnProjection.get().getOriginalName(), null);
+        ColumnProjection originalColumn = new 
ColumnProjection(columnProjection.get().getOriginalOwner(), 
columnProjection.get().getOriginalName(), null, 
selectStatementContext.getDatabaseType());
         Map<String, String> expressionTableNames = 
tablesContext.findTableNamesByColumnProjection(Collections.singletonList(originalColumn),
 database.getSchema(schemaName));
         Optional<String> tableName = findTableName(originalColumn, 
expressionTableNames);
         if (!tableName.isPresent()) {
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/aware/DatabaseTypeAware.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/aware/DatabaseTypeAware.java
new file mode 100644
index 00000000000..6be4fc28ab6
--- /dev/null
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/aware/DatabaseTypeAware.java
@@ -0,0 +1,33 @@
+/*
+ * 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.encrypt.rewrite.aware;
+
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
+
+/**
+ * Database type aware.
+ */
+public interface DatabaseTypeAware {
+    
+    /**
+     * Set database type.
+     * 
+     * @param databaseType database type
+     */
+    void setDatabaseType(DatabaseType databaseType);
+}
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilder.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilder.java
index ecac5d467a5..b1c99c15bfe 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilder.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilder.java
@@ -19,14 +19,15 @@ package org.apache.shardingsphere.encrypt.rewrite.parameter;
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseNameAware;
+import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseTypeAware;
 import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptConditionsAware;
+import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
 import org.apache.shardingsphere.encrypt.rewrite.condition.EncryptCondition;
 import 
org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter.EncryptAssignmentParameterRewriter;
 import 
org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter.EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter;
 import 
org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter.EncryptInsertValueParameterRewriter;
 import 
org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter.EncryptPredicateParameterRewriter;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.infra.rewrite.parameter.rewriter.ParameterRewriter;
@@ -83,5 +84,8 @@ public final class EncryptParameterRewriterBuilder implements 
ParameterRewriterB
         if (toBeAddedParamRewriter instanceof DatabaseNameAware) {
             ((DatabaseNameAware) 
toBeAddedParamRewriter).setDatabaseName(databaseName);
         }
+        if (toBeAddedParamRewriter instanceof DatabaseTypeAware) {
+            ((DatabaseTypeAware) 
toBeAddedParamRewriter).setDatabaseType(sqlStatementContext.getDatabaseType());
+        }
     }
 }
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java
index ea68f1e3973..9bb253234ed 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGenerator.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.encrypt.rewrite.token.generator;
 
 import lombok.Setter;
+import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseTypeAware;
 import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.encrypt.rule.EncryptTable;
@@ -26,6 +27,7 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.Projecti
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.ddl.CreateTableStatementContext;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.CollectionSQLTokenGenerator;
 import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.SQLToken;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.RemoveToken;
@@ -44,10 +46,12 @@ import java.util.Optional;
  * Create table token generator for encrypt.
  */
 @Setter
-public final class EncryptCreateTableTokenGenerator implements 
CollectionSQLTokenGenerator<CreateTableStatementContext>, EncryptRuleAware {
+public final class EncryptCreateTableTokenGenerator implements 
CollectionSQLTokenGenerator<CreateTableStatementContext>, EncryptRuleAware, 
DatabaseTypeAware {
     
     private EncryptRule encryptRule;
     
+    private DatabaseType databaseType;
+    
     @Override
     public boolean isGenerateSQLToken(final SQLStatementContext 
sqlStatementContext) {
         return sqlStatementContext instanceof CreateTableStatementContext && 
!(((CreateTableStatementContext) 
sqlStatementContext).getSqlStatement()).getColumnDefinitions().isEmpty();
@@ -96,6 +100,6 @@ public final class EncryptCreateTableTokenGenerator 
implements CollectionSQLToke
     }
     
     private Collection<Projection> getColumnProjections(final IdentifierValue 
columnIdentifier) {
-        return Collections.singleton(new ColumnProjection(null, 
columnIdentifier, null));
+        return Collections.singleton(new ColumnProjection(null, 
columnIdentifier, null, databaseType));
     }
 }
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
index 87f42d4513d..589c8773340 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.encrypt.rewrite.token.generator;
 
 import com.google.common.base.Preconditions;
 import lombok.Setter;
+import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseTypeAware;
 import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.encrypt.rule.EncryptTable;
@@ -27,10 +28,11 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.Projecti
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.binder.type.IndexAvailable;
+import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.CollectionSQLTokenGenerator;
 import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.SQLToken;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.SubstitutableColumnNameToken;
-import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 
@@ -43,10 +45,12 @@ import java.util.Optional;
  * Index column token generator for encrypt.
  */
 @Setter
-public final class EncryptIndexColumnTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, EncryptRuleAware {
+public final class EncryptIndexColumnTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, EncryptRuleAware, 
DatabaseTypeAware {
     
     private EncryptRule encryptRule;
     
+    private DatabaseType databaseType;
+    
     @Override
     public boolean isGenerateSQLToken(final SQLStatementContext 
sqlStatementContext) {
         return sqlStatementContext instanceof IndexAvailable;
@@ -85,6 +89,6 @@ public final class EncryptIndexColumnTokenGenerator 
implements CollectionSQLToke
     }
     
     private Collection<Projection> getColumnProjections(final String 
columnName, final QuoteCharacter quoteCharacter) {
-        return Collections.singletonList(new ColumnProjection(null, new 
IdentifierValue(columnName, quoteCharacter), null));
+        return Collections.singletonList(new ColumnProjection(null, new 
IdentifierValue(columnName, quoteCharacter), null, databaseType));
     }
 }
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java
index 9ac1da7e1fe..d4ccbe689f9 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptOrderByItemTokenGenerator.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.encrypt.rewrite.token.generator;
 
 import lombok.Setter;
+import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseTypeAware;
 import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.encrypt.rule.EncryptTable;
@@ -28,12 +29,13 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.Col
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
 import org.apache.shardingsphere.infra.database.DatabaseTypeEngine;
+import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.CollectionSQLTokenGenerator;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.aware.SchemaMetaDataAware;
 import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.SQLToken;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.SubstitutableColumnNameToken;
-import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ColumnOrderByItemSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
@@ -49,7 +51,7 @@ import java.util.Optional;
  * Order by item token generator for encrypt.
  */
 @Setter
-public final class EncryptOrderByItemTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, SchemaMetaDataAware, 
EncryptRuleAware {
+public final class EncryptOrderByItemTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, SchemaMetaDataAware, 
EncryptRuleAware, DatabaseTypeAware {
     
     private String databaseName;
     
@@ -57,6 +59,8 @@ public final class EncryptOrderByItemTokenGenerator 
implements CollectionSQLToke
     
     private EncryptRule encryptRule;
     
+    private DatabaseType databaseType;
+    
     @Override
     public boolean isGenerateSQLToken(final SQLStatementContext 
sqlStatementContext) {
         return sqlStatementContext instanceof SelectStatementContext && 
containsOrderByItem(sqlStatementContext);
@@ -130,6 +134,6 @@ public final class EncryptOrderByItemTokenGenerator 
implements CollectionSQLToke
     }
     
     private Collection<Projection> createColumnProjections(final String 
columnName, final QuoteCharacter quoteCharacter) {
-        return Collections.singleton(new ColumnProjection(null, new 
IdentifierValue(columnName, quoteCharacter), null));
+        return Collections.singleton(new ColumnProjection(null, new 
IdentifierValue(columnName, quoteCharacter), null, databaseType));
     }
 }
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
index eb2de9253c6..ef4f2d8b0f6 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.encrypt.rewrite.token.generator;
 
 import lombok.Setter;
 import 
org.apache.shardingsphere.encrypt.exception.syntax.UnsupportedEncryptSQLException;
+import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseTypeAware;
 import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.encrypt.rule.EncryptTable;
@@ -28,13 +29,14 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.Col
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.binder.type.WhereAvailable;
 import org.apache.shardingsphere.infra.database.DatabaseTypeEngine;
+import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.CollectionSQLTokenGenerator;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.aware.SchemaMetaDataAware;
 import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.SQLToken;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.SubstitutableColumnNameToken;
 import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
@@ -53,7 +55,7 @@ import java.util.Optional;
  * Predicate column token generator for encrypt.
  */
 @Setter
-public final class EncryptPredicateColumnTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, SchemaMetaDataAware, 
EncryptRuleAware {
+public final class EncryptPredicateColumnTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, SchemaMetaDataAware, 
EncryptRuleAware, DatabaseTypeAware {
     
     private String databaseName;
     
@@ -61,6 +63,8 @@ public final class EncryptPredicateColumnTokenGenerator 
implements CollectionSQL
     
     private EncryptRule encryptRule;
     
+    private DatabaseType databaseType;
+    
     @Override
     public boolean isGenerateSQLToken(final SQLStatementContext 
sqlStatementContext) {
         return sqlStatementContext instanceof WhereAvailable && 
!((WhereAvailable) sqlStatementContext).getWhereSegments().isEmpty();
@@ -133,6 +137,6 @@ public final class EncryptPredicateColumnTokenGenerator 
implements CollectionSQL
     }
     
     private Collection<Projection> createColumnProjections(final String 
columnName, final QuoteCharacter quoteCharacter) {
-        return Collections.singletonList(new ColumnProjection(null, new 
IdentifierValue(columnName, quoteCharacter), null));
+        return Collections.singletonList(new ColumnProjection(null, new 
IdentifierValue(columnName, quoteCharacter), null, databaseType));
     }
 }
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java
index 75980dd3e31..b1ccadde705 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGenerator.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.encrypt.rewrite.token.generator;
 
 import com.google.common.base.Preconditions;
 import lombok.Setter;
+import org.apache.shardingsphere.encrypt.rewrite.aware.DatabaseTypeAware;
 import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.encrypt.rule.EncryptTable;
@@ -31,6 +32,7 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.Sho
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
 import org.apache.shardingsphere.infra.database.DatabaseTypeEngine;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.CollectionSQLTokenGenerator;
 import 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.aware.PreviousSQLTokensAware;
@@ -57,7 +59,7 @@ import java.util.Optional;
  * Projection token generator for encrypt.
  */
 @Setter
-public final class EncryptProjectionTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, PreviousSQLTokensAware, 
SchemaMetaDataAware, EncryptRuleAware {
+public final class EncryptProjectionTokenGenerator implements 
CollectionSQLTokenGenerator<SQLStatementContext>, PreviousSQLTokensAware, 
SchemaMetaDataAware, EncryptRuleAware, DatabaseTypeAware {
     
     private List<SQLToken> previousSQLTokens;
     
@@ -67,6 +69,8 @@ public final class EncryptProjectionTokenGenerator implements 
CollectionSQLToken
     
     private Map<String, ShardingSphereSchema> schemas;
     
+    private DatabaseType databaseType;
+    
     @Override
     public boolean isGenerateSQLToken(final SQLStatementContext 
sqlStatementContext) {
         return sqlStatementContext instanceof SelectStatementContext && 
!((SelectStatementContext) sqlStatementContext).getAllTables().isEmpty();
@@ -125,7 +129,7 @@ public final class EncryptProjectionTokenGenerator 
implements CollectionSQLToken
             String tableName = columnTableNames.get(each.getExpression());
             Optional<EncryptTable> encryptTable = null == tableName ? 
Optional.empty() : encryptRule.findEncryptTable(tableName);
             if (!encryptTable.isPresent() || 
!encryptTable.get().isEncryptColumn(each.getColumnLabel()) || 
containsTableSubquery(selectStatementContext)) {
-                projections.add(each.getAlias().map(optional -> (Projection) 
new ColumnProjection(null, optional, null)).orElse(each));
+                projections.add(each.getAlias().map(optional -> (Projection) 
new ColumnProjection(null, optional, null, databaseType)).orElse(each));
             } else if (each instanceof ColumnProjection) {
                 
projections.addAll(generateProjections(encryptTable.get().getEncryptColumn(((ColumnProjection)
 each).getName().getValue()), (ColumnProjection) each, subqueryType, true, 
segment));
             }
@@ -147,7 +151,7 @@ public final class EncryptProjectionTokenGenerator 
implements CollectionSQLToken
     
     private ColumnProjection buildColumnProjection(final 
ColumnProjectionSegment segment) {
         IdentifierValue owner = 
segment.getColumn().getOwner().map(OwnerSegment::getIdentifier).orElse(null);
-        return new ColumnProjection(owner, 
segment.getColumn().getIdentifier(), segment.getAliasName().isPresent() ? 
segment.getAlias().orElse(null) : null);
+        return new ColumnProjection(owner, 
segment.getColumn().getIdentifier(), segment.getAliasName().isPresent() ? 
segment.getAlias().orElse(null) : null, databaseType);
     }
     
     private Map<String, String> getColumnTableNames(final 
SelectStatementContext selectStatementContext) {
@@ -184,31 +188,31 @@ public final class EncryptProjectionTokenGenerator 
implements CollectionSQLToken
         if (shorthand || !column.getOwner().isPresent()) {
             return column;
         }
-        return new ColumnProjection(null, column.getName(), 
column.getAlias().isPresent() ? column.getAlias().get() : null);
+        return new ColumnProjection(null, column.getName(), 
column.getAlias().isPresent() ? column.getAlias().get() : null, databaseType);
     }
     
     private ColumnProjection generatePredicateSubqueryProjection(final 
EncryptColumn encryptColumn, final ColumnProjection column) {
         Optional<AssistedQueryColumnItem> assistedQueryColumn = 
encryptColumn.getAssistedQuery();
         if (assistedQueryColumn.isPresent()) {
-            return new ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(assistedQueryColumn.get().getName(), 
column.getName().getQuoteCharacter()), null);
+            return new ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(assistedQueryColumn.get().getName(), 
column.getName().getQuoteCharacter()), null, databaseType);
         }
         String cipherColumn = encryptColumn.getCipher().getName();
-        return new ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(cipherColumn, column.getName().getQuoteCharacter()), null);
+        return new ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(cipherColumn, column.getName().getQuoteCharacter()), null, 
databaseType);
     }
     
     private Collection<ColumnProjection> 
generateTableSubqueryProjections(final EncryptColumn encryptColumn, final 
ColumnProjection column, final boolean shorthand) {
         Collection<ColumnProjection> result = new LinkedList<>();
         result.add(distinctOwner(new 
ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(encryptColumn.getCipher().getName(),
-                column.getName().getQuoteCharacter()), 
column.getAlias().orElse(column.getName())), shorthand));
+                column.getName().getQuoteCharacter()), 
column.getAlias().orElse(column.getName()), databaseType), shorthand));
         encryptColumn.getAssistedQuery().ifPresent(optional -> result.add(
-                new ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(optional.getName(), column.getName().getQuoteCharacter()), 
null)));
+                new ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(optional.getName(), column.getName().getQuoteCharacter()), 
null, databaseType)));
         return result;
     }
     
     private Collection<ColumnProjection> 
generateExistsSubqueryProjections(final EncryptColumn encryptColumn, final 
ColumnProjection column, final boolean shorthand) {
         Collection<ColumnProjection> result = new LinkedList<>();
         result.add(distinctOwner(new 
ColumnProjection(column.getOwner().orElse(null), new 
IdentifierValue(encryptColumn.getCipher().getName(),
-                column.getName().getQuoteCharacter()), null), shorthand));
+                column.getName().getQuoteCharacter()), null, databaseType), 
shorthand));
         return result;
     }
     
@@ -217,7 +221,7 @@ public final class EncryptProjectionTokenGenerator 
implements CollectionSQLToken
         IdentifierValue owner = (null == segment || 
!segment.getOwner().isPresent()) ? column.getOwner().orElse(null) : 
segment.getOwner().get().getIdentifier();
         return new ColumnProjection(owner, new 
IdentifierValue(queryColumnName, column.getName().getQuoteCharacter()), 
column.getAlias().isPresent()
                 ? column.getAlias().get()
-                : column.getName());
+                : column.getName(), databaseType);
     }
     
     private ShorthandProjection getShorthandProjection(final 
ShorthandProjectionSegment segment, final ProjectionsContext 
projectionsContext) {
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertCipherNameTokenGenerator.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertCipherNameTokenGenerator.java
index 684073a6ce0..7911af69403 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertCipherNameTokenGenerator.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertCipherNameTokenGenerator.java
@@ -63,7 +63,8 @@ public final class EncryptInsertCipherNameTokenGenerator 
implements CollectionSQ
         for (ColumnSegment each : insertColumnsSegment.get().getColumns()) {
             String columnName = each.getIdentifier().getValue();
             if (encryptTable.isEncryptColumn(columnName)) {
-                Collection<Projection> projections = Collections.singleton(new 
ColumnProjection(null, 
encryptTable.getEncryptColumn(columnName).getCipher().getName(), null));
+                Collection<Projection> projections =
+                        Collections.singleton(new ColumnProjection(null, 
encryptTable.getEncryptColumn(columnName).getCipher().getName(), null, 
insertStatementContext.getDatabaseType()));
                 result.add(new 
SubstitutableColumnNameToken(each.getStartIndex(), each.getStopIndex(), 
projections));
             }
         }
diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
index e22f6587f04..4fea3389099 100644
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
+++ 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
@@ -88,7 +88,7 @@ class EncryptProjectionTokenGeneratorTest {
         
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
         SimpleTableSegment doctorOneTable = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("doctor1")));
         when(sqlStatementContext.getTablesContext()).thenReturn(new 
TablesContext(Arrays.asList(doctorTable, doctorOneTable), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE")));
-        
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection("a", "mobile", null)));
+        
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection("a", "mobile", null, mock(DatabaseType.class))));
         Collection<SQLToken> actual = 
generator.generateSQLTokens(sqlStatementContext);
         assertThat(actual.size(), is(1));
     }
@@ -106,7 +106,7 @@ class EncryptProjectionTokenGeneratorTest {
         
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
         SimpleTableSegment sameDoctorTable = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("doctor")));
         when(sqlStatementContext.getTablesContext()).thenReturn(new 
TablesContext(Arrays.asList(doctorTable, sameDoctorTable), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE")));
-        
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection("a", "mobile", null)));
+        
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection("a", "mobile", null, mock(DatabaseType.class))));
         Collection<SQLToken> actual = 
generator.generateSQLTokens(sqlStatementContext);
         assertThat(actual.size(), is(1));
     }
@@ -123,7 +123,7 @@ class EncryptProjectionTokenGeneratorTest {
         SimpleTableSegment doctorTable = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("doctor")));
         SimpleTableSegment doctorOneTable = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("doctor1")));
         when(sqlStatementContext.getTablesContext()).thenReturn(new 
TablesContext(Arrays.asList(doctorTable, doctorOneTable), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE")));
-        
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection("doctor", "mobile", null)));
+        
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection("doctor", "mobile", null, mock(DatabaseType.class))));
         Collection<SQLToken> actual = 
generator.generateSQLTokens(sqlStatementContext);
         assertThat(actual.size(), is(1));
     }
diff --git 
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
 
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
index 710d6f39b4a..e8b031e0fca 100644
--- 
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
+++ 
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.mask.merge.dql;
 
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
 import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.mask.rule.MaskRule;
@@ -35,6 +36,7 @@ import java.util.Optional;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 @ExtendWith(MockitoExtension.class)
@@ -53,7 +55,7 @@ class MaskAlgorithmMetaDataTest {
     @Test
     void assertFindMaskAlgorithmByColumnIndex() {
         when(maskRule.findMaskAlgorithm("t_order", 
"order_id")).thenReturn(Optional.of(TypedSPILoader.getService(MaskAlgorithm.class,
 "MD5")));
-        
when(selectStatementContext.getProjectionsContext().getExpandProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection(null, "order_id", null)));
+        
when(selectStatementContext.getProjectionsContext().getExpandProjections()).thenReturn(Collections.singletonList(new
 ColumnProjection(null, "order_id", null, mock(DatabaseType.class))));
         
when(selectStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_order"));
         Optional<MaskAlgorithm> actual = new MaskAlgorithmMetaData(database, 
maskRule, selectStatementContext).findMaskAlgorithmByColumnIndex(1);
         assertTrue(actual.isPresent());
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
index 759bf52d643..a031298f9ed 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
@@ -128,7 +128,8 @@ public final class ProjectionEngine {
     
     private ColumnProjection createProjection(final ColumnProjectionSegment 
projectionSegment) {
         IdentifierValue owner = 
projectionSegment.getColumn().getOwner().isPresent() ? 
projectionSegment.getColumn().getOwner().get().getIdentifier() : null;
-        return new ColumnProjection(owner, 
projectionSegment.getColumn().getIdentifier(), 
projectionSegment.getAliasName().isPresent() ? 
projectionSegment.getAlias().orElse(null) : null);
+        return new ColumnProjection(owner, 
projectionSegment.getColumn().getIdentifier(), 
projectionSegment.getAliasName().isPresent() ? 
projectionSegment.getAlias().orElse(null) : null,
+                databaseType);
     }
     
     private ExpressionProjection createProjection(final 
ExpressionProjectionSegment projectionSegment) {
@@ -168,10 +169,11 @@ public final class ProjectionEngine {
         ShardingSpherePreconditions.checkNotNull(schema, () -> new 
SchemaNotFoundException(schemaName));
         Collection<ColumnProjection> result = new LinkedList<>();
         if (null == owner) {
-            schema.getVisibleColumnNames(tableName).stream().map(each -> new 
ColumnProjection(table.getAlias()
-                    .orElse(((SimpleTableSegment) 
table).getTableName().getIdentifier()), new IdentifierValue(each, 
databaseType.getQuoteCharacter()), null)).forEach(result::add);
+            schema.getVisibleColumnNames(tableName).stream().map(each -> new 
ColumnProjection(table.getAlias().orElse(((SimpleTableSegment) 
table).getTableName().getIdentifier()),
+                    new IdentifierValue(each, 
databaseType.getQuoteCharacter()), null, databaseType)).forEach(result::add);
         } else if (owner.getValue().equalsIgnoreCase(tableAlias)) {
-            schema.getVisibleColumnNames(tableName).stream().map(each -> new 
ColumnProjection(owner, new IdentifierValue(each, 
databaseType.getQuoteCharacter()), null)).forEach(result::add);
+            schema.getVisibleColumnNames(tableName).stream().map(each -> new 
ColumnProjection(owner, new IdentifierValue(each, 
databaseType.getQuoteCharacter()), null, databaseType))
+                    .forEach(result::add);
         }
         return result;
     }
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjection.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjection.java
index a997a751ded..6e7517b28d9 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjection.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjection.java
@@ -64,11 +64,6 @@ public class AggregationProjection implements Projection {
         return getAlias().isPresent() ? 
ProjectionUtils.getColumnLabelFromAlias(getAlias().get(), databaseType) : 
getColumnName();
     }
     
-    @Override
-    public String getExpression() {
-        return expression;
-    }
-    
     @Override
     public final Optional<IdentifierValue> getAlias() {
         return Optional.ofNullable(alias);
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/ColumnProjection.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/ColumnProjection.java
index 6f2fcb80f2c..881e7da3c65 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/ColumnProjection.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/ColumnProjection.java
@@ -23,7 +23,9 @@ import lombok.RequiredArgsConstructor;
 import lombok.Setter;
 import lombok.ToString;
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.Projection;
+import 
org.apache.shardingsphere.infra.binder.segment.select.projection.util.ProjectionUtils;
 import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 
 import java.util.Optional;
@@ -44,23 +46,25 @@ public final class ColumnProjection implements Projection {
     
     private final IdentifierValue alias;
     
+    private final DatabaseType databaseType;
+    
     private IdentifierValue originalOwner;
     
     private IdentifierValue originalName;
     
-    public ColumnProjection(final String owner, final String name, final 
String alias) {
+    public ColumnProjection(final String owner, final String name, final 
String alias, final DatabaseType databaseType) {
         this(null == owner ? null : new IdentifierValue(owner, 
QuoteCharacter.NONE), new IdentifierValue(name, QuoteCharacter.NONE),
-                null == alias ? null : new IdentifierValue(alias, 
QuoteCharacter.NONE));
+                null == alias ? null : new IdentifierValue(alias, 
QuoteCharacter.NONE), databaseType);
     }
     
     @Override
     public String getColumnName() {
-        return null == owner ? name.getValue() : owner.getValue() + "." + 
name.getValue();
+        return ProjectionUtils.getColumnNameFromColumn(name, databaseType);
     }
     
     @Override
     public String getColumnLabel() {
-        return 
getAlias().map(IdentifierValue::getValue).orElse(name.getValue());
+        return getAlias().isPresent() ? 
ProjectionUtils.getColumnLabelFromAlias(getAlias().get(), databaseType) : 
getColumnName();
     }
     
     @Override
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/util/ProjectionUtils.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/util/ProjectionUtils.java
index 2a6c0c8aea7..e0519c8e7df 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/util/ProjectionUtils.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/util/ProjectionUtils.java
@@ -19,11 +19,11 @@ package 
org.apache.shardingsphere.infra.binder.segment.select.projection.util;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
 import 
org.apache.shardingsphere.infra.database.opengauss.OpenGaussDatabaseType;
 import org.apache.shardingsphere.infra.database.oracle.OracleDatabaseType;
 import 
org.apache.shardingsphere.infra.database.postgresql.PostgreSQLDatabaseType;
 import org.apache.shardingsphere.infra.database.spi.DatabaseType;
-import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 
 /**
@@ -40,16 +40,31 @@ public final class ProjectionUtils {
      * @return column label
      */
     public static String getColumnLabelFromAlias(final IdentifierValue alias, 
final DatabaseType databaseType) {
-        if (QuoteCharacter.NONE != alias.getQuoteCharacter()) {
-            return alias.getValue();
+        return getIdentifierValueByDatabaseType(alias, databaseType);
+    }
+    
+    private static String getIdentifierValueByDatabaseType(IdentifierValue 
identifierValue, DatabaseType databaseType) {
+        if (QuoteCharacter.NONE != identifierValue.getQuoteCharacter()) {
+            return identifierValue.getValue();
         }
         if (databaseType instanceof PostgreSQLDatabaseType || databaseType 
instanceof OpenGaussDatabaseType) {
-            return alias.getValue().toLowerCase();
+            return identifierValue.getValue().toLowerCase();
         }
         if (databaseType instanceof OracleDatabaseType) {
-            return alias.getValue().toUpperCase();
+            return identifierValue.getValue().toUpperCase();
         }
-        return alias.getValue();
+        return identifierValue.getValue();
+    }
+    
+    /**
+     * Get column name from column.
+     *
+     * @param columnName column name
+     * @param databaseType database type
+     * @return column name
+     */
+    public static String getColumnNameFromColumn(final IdentifierValue 
columnName, final DatabaseType databaseType) {
+        return getIdentifierValueByDatabaseType(columnName, databaseType);
     }
     
     /**
diff --git 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
index 18ce50d0bdb..74e21a14044 100644
--- 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
+++ 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
@@ -21,6 +21,7 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.pagination.Paginati
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.Projection;
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.ProjectionsContext;
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
@@ -40,6 +41,7 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
 
 class RowNumberPaginationContextEngineTest {
     
@@ -57,7 +59,7 @@ class RowNumberPaginationContextEngineTest {
     
     @Test
     void 
assertCreatePaginationContextWhenRowNumberAliasIsPresentAndRowNumberPredicatesIsEmpty()
 {
-        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
+        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS, mock(DatabaseType.class));
         ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, 
false, Collections.singleton(projectionWithRowNumberAlias));
         PaginationContext paginationContext = new 
RowNumberPaginationContextEngine().createPaginationContext(Collections.emptyList(),
 projectionsContext, Collections.emptyList());
         assertFalse(paginationContext.getOffsetSegment().isPresent());
@@ -86,7 +88,7 @@ class RowNumberPaginationContextEngineTest {
     
     @Test
     void 
assertCreatePaginationContextWhenRowNumberAliasIsPresentAndRowNumberPredicatesNotEmpty()
 {
-        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
+        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS, mock(DatabaseType.class));
         ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, 
false, Collections.singleton(projectionWithRowNumberAlias));
         AndPredicate andPredicate = new AndPredicate();
         ColumnSegment left = new ColumnSegment(0, 10, new 
IdentifierValue(ROW_NUMBER_COLUMN_NAME));
@@ -99,7 +101,7 @@ class RowNumberPaginationContextEngineTest {
     
     @Test
     void 
assertCreatePaginationContextWhenParameterMarkerRowNumberValueSegment() {
-        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
+        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS, mock(DatabaseType.class));
         ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, 
false, Collections.singleton(projectionWithRowNumberAlias));
         ColumnSegment left = new ColumnSegment(0, 10, new 
IdentifierValue(ROW_NUMBER_COLUMN_NAME));
         ParameterMarkerExpressionSegment right = new 
ParameterMarkerExpressionSegment(0, 10, 0);
@@ -113,7 +115,7 @@ class RowNumberPaginationContextEngineTest {
     }
     
     private void 
assertCreatePaginationContextWhenRowNumberAliasPresentAndRowNumberPredicatedNotEmptyWithGivenOperator(final
 String operator) {
-        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
+        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS, mock(DatabaseType.class));
         ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, 
false, Collections.singleton(projectionWithRowNumberAlias));
         ColumnSegment left = new ColumnSegment(0, 10, new 
IdentifierValue(ROW_NUMBER_COLUMN_NAME));
         LiteralExpressionSegment right = new LiteralExpressionSegment(0, 10, 
100);
@@ -129,7 +131,7 @@ class RowNumberPaginationContextEngineTest {
     }
     
     private void 
assertCreatePaginationContextWhenOffsetSegmentInstanceOfNumberLiteralRowNumberValueSegmentWithGivenOperator(final
 String operator) {
-        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
+        Projection projectionWithRowNumberAlias = new ColumnProjection(null, 
ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS, mock(DatabaseType.class));
         ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, 
false, Collections.singleton(projectionWithRowNumberAlias));
         ColumnSegment left = new ColumnSegment(0, 10, new 
IdentifierValue(ROW_NUMBER_COLUMN_NAME));
         LiteralExpressionSegment right = new LiteralExpressionSegment(0, 10, 
100);
diff --git 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/ProjectionsContextTest.java
 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/ProjectionsContextTest.java
index 2f45cc770f4..194b9233001 100644
--- 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/ProjectionsContextTest.java
+++ 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/ProjectionsContextTest.java
@@ -118,11 +118,11 @@ class ProjectionsContextTest {
     }
     
     private ColumnProjection getColumnProjection() {
-        return new ColumnProjection("table", "name", null);
+        return new ColumnProjection("table", "name", null, 
mock(DatabaseType.class));
     }
     
     private ColumnProjection getColumnProjectionWithAlias() {
-        return new ColumnProjection("table", "name", "n");
+        return new ColumnProjection("table", "name", "n", 
mock(DatabaseType.class));
     }
     
     private AggregationProjection getAggregationProjection() {
@@ -136,9 +136,9 @@ class ProjectionsContextTest {
     
     @Test
     void assertGetExpandProjections() {
-        ColumnProjection columnProjection1 = new ColumnProjection(null, 
"col1", null);
-        ColumnProjection columnProjection2 = new ColumnProjection(null, 
"col2", null);
-        ColumnProjection columnProjection3 = new ColumnProjection(null, 
"col3", null);
+        ColumnProjection columnProjection1 = new ColumnProjection(null, 
"col1", null, mock(DatabaseType.class));
+        ColumnProjection columnProjection2 = new ColumnProjection(null, 
"col2", null, mock(DatabaseType.class));
+        ColumnProjection columnProjection3 = new ColumnProjection(null, 
"col3", null, mock(DatabaseType.class));
         DerivedProjection derivedProjection = new DerivedProjection("col3", 
new IdentifierValue("a3"), null);
         ShorthandProjection shorthandProjection = new 
ShorthandProjection(null, Arrays.asList(columnProjection2, columnProjection3));
         ProjectionsContext actual = new ProjectionsContext(0, 0, false, 
Arrays.asList(columnProjection1, shorthandProjection, derivedProjection));
diff --git 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngineTest.java
 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngineTest.java
index 0b77669eb9e..9350a3d07b3 100644
--- 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngineTest.java
+++ 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngineTest.java
@@ -25,10 +25,10 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.Exp
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ParameterMarkerProjection;
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ShorthandProjection;
 import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
 import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import org.apache.shardingsphere.infra.exception.SchemaNotFoundException;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.database.enums.QuoteCharacter;
 import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.sql.parser.sql.common.enums.AggregationType;
 import org.apache.shardingsphere.sql.parser.sql.common.enums.JoinType;
@@ -106,8 +106,8 @@ class ProjectionEngineTest {
         assertThat(actual.get(), instanceOf(ShorthandProjection.class));
         assertThat(((ShorthandProjection) 
actual.get()).getColumnProjections().size(), is(2));
         Collection<ColumnProjection> columnProjections = new LinkedList<>();
-        columnProjections.add(new ColumnProjection("t_order", "order_id", 
null));
-        columnProjections.add(new ColumnProjection("t_order", "content", 
null));
+        columnProjections.add(new ColumnProjection("t_order", "order_id", 
null, databaseType));
+        columnProjections.add(new ColumnProjection("t_order", "content", null, 
databaseType));
         assertThat(((ShorthandProjection) 
actual.get()).getColumnProjections(), is(columnProjections));
     }
     
@@ -196,9 +196,9 @@ class ProjectionEngineTest {
         Collection<ColumnProjection> columnProjections = 
((ShorthandProjection) actual.get()).getColumnProjections();
         assertThat(columnProjections.size(), is(3));
         Iterator<ColumnProjection> iterator = columnProjections.iterator();
-        assertThat(iterator.next(), is(new ColumnProjection("t_order", 
"order_id", null)));
-        assertThat(iterator.next(), is(new ColumnProjection("t_order", 
"customer_id", null)));
-        assertThat(iterator.next(), is(new ColumnProjection("t_customer", 
"customer_id", null)));
+        assertThat(iterator.next(), is(new ColumnProjection("t_order", 
"order_id", null, databaseType)));
+        assertThat(iterator.next(), is(new ColumnProjection("t_order", 
"customer_id", null, databaseType)));
+        assertThat(iterator.next(), is(new ColumnProjection("t_customer", 
"customer_id", null, databaseType)));
     }
     
     @Test
@@ -281,41 +281,41 @@ class ProjectionEngineTest {
     private Collection<Projection> 
crateExpectedColumnsWithoutOwnerForPostgreSQL() {
         Collection<Projection> result = new LinkedHashSet<>();
         DatabaseType postgresDatabaseType = 
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("user_id", postgresDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("order_id", postgresDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("creation_date", postgresDatabaseType.getQuoteCharacter()), 
null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("status", postgresDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("merchant_id", postgresDatabaseType.getQuoteCharacter()), 
null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("remark", postgresDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("item_id", postgresDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("product_id", postgresDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("quantity", postgresDatabaseType.getQuoteCharacter()), null));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("user_id", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("order_id", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("creation_date", postgresDatabaseType.getQuoteCharacter()), 
null, postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("status", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("merchant_id", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("remark", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("item_id", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("product_id", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("quantity", postgresDatabaseType.getQuoteCharacter()), null, 
postgresDatabaseType));
         return result;
     }
     
     private Collection<Projection> crateExpectedColumnsWithoutOwnerForMySQL() {
         Collection<Projection> result = new LinkedHashSet<>();
         DatabaseType mysqlDatabaseType = 
TypedSPILoader.getService(DatabaseType.class, "MySQL");
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("order_id", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("user_id", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("creation_date", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("item_id", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("product_id", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("quantity", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("status", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("merchant_id", mysqlDatabaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("remark", mysqlDatabaseType.getQuoteCharacter()), null));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("order_id", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("user_id", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("creation_date", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("item_id", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("product_id", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("i"), new 
IdentifierValue("quantity", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("status", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("merchant_id", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("remark", mysqlDatabaseType.getQuoteCharacter()), null, 
mysqlDatabaseType));
         return result;
     }
     
     private Collection<Projection> crateExpectedColumnsWithOwner(final 
DatabaseType databaseType) {
         Collection<Projection> result = new LinkedHashSet<>();
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("order_id", databaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("user_id", databaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("status", databaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("merchant_id", databaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("remark", databaseType.getQuoteCharacter()), null));
-        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("creation_date", databaseType.getQuoteCharacter()), null));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("order_id", databaseType.getQuoteCharacter()), null, 
databaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("user_id", databaseType.getQuoteCharacter()), null, 
databaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("status", databaseType.getQuoteCharacter()), null, 
databaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("merchant_id", databaseType.getQuoteCharacter()), null, 
databaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("remark", databaseType.getQuoteCharacter()), null, 
databaseType));
+        result.add(new ColumnProjection(new IdentifierValue("o"), new 
IdentifierValue("creation_date", databaseType.getQuoteCharacter()), null, 
databaseType));
         return result;
     }
     
diff --git 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjectionTest.java
 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjectionTest.java
index 256462807a5..4e6bbaf5201 100644
--- 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjectionTest.java
+++ 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/projection/impl/AggregationProjectionTest.java
@@ -36,14 +36,14 @@ class AggregationProjectionTest {
     
     @Test
     void assertGetColumnName() {
-        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )",
-                null, TypedSPILoader.getService(DatabaseType.class, 
"MySQL")).getColumnName(), is("COUNT( A.\"DIRECTION\" )"));
-        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )",
-                null, TypedSPILoader.getService(DatabaseType.class, 
"PostgreSQL")).getColumnName(), is("count"));
-        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null,
-                TypedSPILoader.getService(DatabaseType.class, 
"openGauss")).getColumnName(), is("count"));
-        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
a.\"direction\" )", null,
-                TypedSPILoader.getService(DatabaseType.class, 
"Oracle")).getColumnName(), is("COUNT(A.\"DIRECTION\")"));
+        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"MySQL")).getColumnName(),
+                is("COUNT( A.\"DIRECTION\" )"));
+        assertThat(new AggregationProjection(AggregationType.COUNT, "count( 
a.\"direction\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"MySQL")).getColumnName(),
+                is("count( a.\"direction\" )"));
+        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"PostgreSQL")).getColumnName(), is("count"));
+        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"openGauss")).getColumnName(), is("count"));
+        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
a.\"direction\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"Oracle")).getColumnName(),
+                is("COUNT(A.\"DIRECTION\")"));
     }
     
     @Test
@@ -81,8 +81,9 @@ class AggregationProjectionTest {
     void assertGetColumnLabelWithoutAlias() {
         assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"MySQL")).getColumnLabel(),
                 is("COUNT( A.\"DIRECTION\" )"));
-        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"PostgreSQL")).getColumnLabel(),
-                is("count"));
+        assertThat(new AggregationProjection(AggregationType.COUNT, "count( 
a.\"direction\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"MySQL")).getColumnLabel(),
+                is("count( a.\"direction\" )"));
+        assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"PostgreSQL")).getColumnLabel(), is("count"));
         assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
A.\"DIRECTION\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"openGauss")).getColumnLabel(),
                 is("count"));
         assertThat(new AggregationProjection(AggregationType.COUNT, "COUNT( 
a.\"direction\" )", null, TypedSPILoader.getService(DatabaseType.class, 
"Oracle")).getColumnLabel(),
diff --git 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java
 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java
index 7f80086dbe7..f6f3d32afad 100644
--- 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java
+++ 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java
@@ -128,7 +128,7 @@ class TablesContextTest {
     @Test
     void assertFindTableNameWhenColumnProjectionWhenSingleTable() {
         SimpleTableSegment tableSegment = createTableSegment("table_1", 
"tbl_1");
-        ColumnProjection columnProjection = new ColumnProjection(null, "col", 
"cl");
+        ColumnProjection columnProjection = new ColumnProjection(null, "col", 
"cl", mock(DatabaseType.class));
         Map<String, String> actual = new 
TablesContext(Collections.singletonList(tableSegment), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE"))
                 
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), 
mock(ShardingSphereSchema.class));
         assertFalse(actual.isEmpty());
@@ -139,7 +139,7 @@ class TablesContextTest {
     void assertFindTableNameWhenColumnProjectionOwnerPresent() {
         SimpleTableSegment tableSegment1 = createTableSegment("table_1", 
"tbl_1");
         SimpleTableSegment tableSegment2 = createTableSegment("table_2", 
"tbl_2");
-        ColumnProjection columnProjection = new ColumnProjection("table_1", 
"col", "cl");
+        ColumnProjection columnProjection = new ColumnProjection("table_1", 
"col", "cl", mock(DatabaseType.class));
         Map<String, String> actual = new 
TablesContext(Arrays.asList(tableSegment1, tableSegment2), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE"))
                 
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), 
mock(ShardingSphereSchema.class));
         assertFalse(actual.isEmpty());
@@ -150,7 +150,7 @@ class TablesContextTest {
     void assertFindTableNameWhenColumnProjectionOwnerAbsent() {
         SimpleTableSegment tableSegment1 = createTableSegment("table_1", 
"tbl_1");
         SimpleTableSegment tableSegment2 = createTableSegment("table_2", 
"tbl_2");
-        ColumnProjection columnProjection = new ColumnProjection(null, "col", 
"cl");
+        ColumnProjection columnProjection = new ColumnProjection(null, "col", 
"cl", mock(DatabaseType.class));
         Map<String, String> actual = new 
TablesContext(Arrays.asList(tableSegment1, tableSegment2), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE"))
                 
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), 
mock(ShardingSphereSchema.class));
         assertTrue(actual.isEmpty());
@@ -162,7 +162,7 @@ class TablesContextTest {
         SimpleTableSegment tableSegment2 = createTableSegment("table_2", 
"tbl_2");
         ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
         
when(schema.getAllColumnNames("table_1")).thenReturn(Collections.singletonList("col"));
-        ColumnProjection columnProjection = new ColumnProjection(null, "col", 
"cl");
+        ColumnProjection columnProjection = new ColumnProjection(null, "col", 
"cl", mock(DatabaseType.class));
         Map<String, String> actual = new 
TablesContext(Arrays.asList(tableSegment1, tableSegment2), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE"))
                 
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), 
schema);
         assertFalse(actual.isEmpty());
@@ -176,7 +176,7 @@ class TablesContextTest {
         ShardingSphereTable table = new ShardingSphereTable("TABLE_1", 
Collections.singletonList(
                 new ShardingSphereColumn("COL", 0, false, false, true, true, 
false)), Collections.emptyList(), Collections.emptyList());
         ShardingSphereSchema schema = new 
ShardingSphereSchema(Stream.of(table).collect(Collectors.toMap(ShardingSphereTable::getName,
 value -> value)), Collections.emptyMap());
-        ColumnProjection columnProjection = new ColumnProjection(null, "COL", 
"CL");
+        ColumnProjection columnProjection = new ColumnProjection(null, "COL", 
"CL", mock(DatabaseType.class));
         Map<String, String> actual = new 
TablesContext(Arrays.asList(tableSegment1, tableSegment2), 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE"))
                 
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), 
schema);
         assertFalse(actual.isEmpty());
diff --git 
a/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/generic/SubstitutableColumnNameTokenTest.java
 
b/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/generic/SubstitutableColumnNameTokenTest.java
index f581a4985aa..3fe9f1b6d71 100644
--- 
a/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/generic/SubstitutableColumnNameTokenTest.java
+++ 
b/infra/rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/generic/SubstitutableColumnNameTokenTest.java
@@ -39,32 +39,33 @@ class SubstitutableColumnNameTokenTest {
     
     @Test
     void assertToString() {
-        Collection<Projection> projections = Collections.singletonList(new 
ColumnProjection(null, "id", null));
+        Collection<Projection> projections = Collections.singletonList(new 
ColumnProjection(null, "id", null, mock(DatabaseType.class)));
         assertThat(new SubstitutableColumnNameToken(0, 1, 
projections).toString(mock(RouteUnit.class)), is("id"));
     }
     
     @Test
     void assertToStringWithQuote() {
         Collection<Projection> projections = Collections.singletonList(new 
ColumnProjection(null,
-                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE)));
+                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE), mock(DatabaseType.class)));
         assertThat(new SubstitutableColumnNameToken(0, 1, projections, 
QuoteCharacter.BACK_QUOTE).toString(mock(RouteUnit.class)), is("`id` AS `id`"));
     }
     
     @Test
     void assertToStringWithOwnerQuote() {
         Collection<Projection> projectionsWithOwnerQuote = 
Collections.singletonList(new ColumnProjection(new IdentifierValue("temp", 
QuoteCharacter.BACK_QUOTE),
-                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE)));
+                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE), mock(DatabaseType.class)));
         assertThat(new SubstitutableColumnNameToken(0, 1, 
projectionsWithOwnerQuote, 
QuoteCharacter.BACK_QUOTE).toString(mock(RouteUnit.class)), is("`temp`.`id` AS 
`id`"));
         Collection<Projection> projectionsWithoutOwnerQuote = 
Collections.singletonList(new ColumnProjection(new IdentifierValue("temp", 
QuoteCharacter.NONE),
-                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE)));
+                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE), mock(DatabaseType.class)));
         assertThat(new SubstitutableColumnNameToken(0, 1, 
projectionsWithoutOwnerQuote, 
QuoteCharacter.BACK_QUOTE).toString(mock(RouteUnit.class)), is("temp.`id` AS 
`id`"));
     }
     
     @Test
     void assertToStringWithSubqueryProjection() {
         Collection<Projection> projections = Arrays.asList(new 
ColumnProjection(new IdentifierValue("temp", QuoteCharacter.BACK_QUOTE),
-                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE)),
-                new SubqueryProjection("(SELECT name FROM t_order)", new 
ColumnProjection(null, "name", null), new IdentifierValue("name"), 
TypedSPILoader.getService(DatabaseType.class, "Oracle")));
+                new IdentifierValue("id", QuoteCharacter.BACK_QUOTE), new 
IdentifierValue("id", QuoteCharacter.BACK_QUOTE), mock(DatabaseType.class)),
+                new SubqueryProjection("(SELECT name FROM t_order)", new 
ColumnProjection(null, "name", null, mock(DatabaseType.class)), new 
IdentifierValue("name"),
+                        TypedSPILoader.getService(DatabaseType.class, 
"Oracle")));
         assertThat(new SubstitutableColumnNameToken(0, 1, projections, 
QuoteCharacter.BACK_QUOTE).toString(mock(RouteUnit.class)),
                 is("`temp`.`id` AS `id`, `name`"));
     }
diff --git 
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetUtilsTest.java
 
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetUtilsTest.java
index 3ab73e7063d..89e8a91b5d0 100644
--- 
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetUtilsTest.java
+++ 
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetUtilsTest.java
@@ -21,6 +21,7 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.Projecti
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.ProjectionsContext;
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
 import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import org.junit.jupiter.api.Test;
 
 import java.sql.ResultSetMetaData;
@@ -53,8 +54,8 @@ class ShardingSphereResultSetUtilsTest {
     void assertCreateColumnLabelAndIndexMapWithSelectWithExpandProjections() 
throws SQLException {
         SelectStatementContext selectStatementContext = 
mock(SelectStatementContext.class);
         List<Projection> projections = new ArrayList<>(2);
-        projections.add(new ColumnProjection(null, "col1", null));
-        projections.add(new ColumnProjection(null, "col2", null));
+        projections.add(new ColumnProjection(null, "col1", null, 
mock(DatabaseType.class)));
+        projections.add(new ColumnProjection(null, "col2", null, 
mock(DatabaseType.class)));
         when(selectStatementContext.getProjectionsContext()).thenReturn(new 
ProjectionsContext(0, 0, false, projections));
         Map<String, Integer> expected = new HashMap<>(2, 1F);
         expected.put("col1", 1);
diff --git 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java
 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java
index 0472c59c3da..4e806e63f65 100644
--- 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java
+++ 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java
@@ -182,7 +182,9 @@ public final class SQLFederationResultSetMetaData extends 
WrapperAdapter impleme
     
     private Optional<String> findTableName(final int column) {
         List<Projection> expandProjections = 
selectStatementContext.getProjectionsContext().getExpandProjections();
-        Projection projection = expandProjections.size() < column ? new 
ColumnProjection(null, resultColumnType.getFieldList().get(column - 
1).getName(), null) : expandProjections.get(column - 1);
+        Projection projection =
+                expandProjections.size() < column ? new ColumnProjection(null, 
resultColumnType.getFieldList().get(column - 1).getName(), null, 
selectStatementContext.getDatabaseType())
+                        : expandProjections.get(column - 1);
         if (projection instanceof ColumnProjection) {
             Map<String, String> tableNamesByColumnProjection =
                     
selectStatementContext.getTablesContext().findTableNamesByColumnProjection(Collections.singletonList((ColumnProjection)
 projection), schema);
diff --git 
a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java
 
b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java
index eb4369af915..542cad57628 100644
--- 
a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java
+++ 
b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.infra.binder.segment.select.projection.Projecti
 import 
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
 import org.apache.shardingsphere.infra.binder.segment.table.TablesContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.database.spi.DatabaseType;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.sqlfederation.compiler.metadata.schema.SQLFederationSchema;
 import org.junit.jupiter.api.AfterEach;
@@ -72,8 +73,9 @@ class SQLFederationResultSetTest {
     
     private SelectStatementContext createSelectStatementContext() {
         SelectStatementContext result = mock(SelectStatementContext.class, 
RETURNS_DEEP_STUBS);
-        List<Projection> projections = Arrays.asList(new ColumnProjection("o", 
"order_id", null), new ColumnProjection("o", "user_id", null), new 
ColumnProjection("o", "status", null),
-                new ColumnProjection("i", "item_id", null));
+        List<Projection> projections = Arrays.asList(new ColumnProjection("o", 
"order_id", null, mock(DatabaseType.class)), new ColumnProjection("o", 
"user_id", null, mock(DatabaseType.class)),
+                new ColumnProjection("o", "status", null, 
mock(DatabaseType.class)),
+                new ColumnProjection("i", "item_id", null, 
mock(DatabaseType.class)));
         
when(result.getProjectionsContext().getExpandProjections()).thenReturn(projections);
         TablesContext tablesContext = mock(TablesContext.class);
         
when(tablesContext.getTableNames()).thenReturn(Collections.emptyList());

Reply via email to