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

sunnianjun 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 10f2ee11d14 Optimize mysql, oracle, sqlserver and sql92 null 
projection parse and support convert to sqlnode (#22554)
10f2ee11d14 is described below

commit 10f2ee11d14da1e1e64c753067735b0baa4af39d
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Thu Dec 1 15:08:15 2022 +0800

    Optimize mysql, oracle, sqlserver and sql92 null projection parse and 
support convert to sqlnode (#22554)
    
    * Optimize mysql, oracle, sqlserver and sql92 null projection parse and 
support convert to sqlnode
    
    * Support information_schema select
---
 .../token/pojo/EncryptLiteralAssignmentToken.java  |  3 ++
 .../executor/FilterableTableScanExecutor.java      |  4 +--
 .../executor/TranslatableTableScanExecutor.java    |  4 +--
 .../impl/LiteralExpressionConverter.java           | 11 +++++---
 .../statement/impl/MySQLStatementSQLVisitor.java   |  4 +--
 .../statement/impl/OracleStatementSQLVisitor.java  |  6 ++--
 .../statement/impl/SQL92StatementSQLVisitor.java   |  4 +--
 .../impl/SQLServerStatementSQLVisitor.java         |  4 +--
 .../sql/parser/sql/common/util/SQLUtil.java        |  4 +++
 .../value/literal/impl/NullLiteralValue.java       | 32 ++++++++++++++++++++++
 .../SQLNodeConverterEngineParameterizedTest.java   |  1 +
 .../segment/expression/ExpressionAssert.java       |  2 +-
 test/parser/src/main/resources/case/dml/insert.xml |  4 +--
 .../parser/src/main/resources/case/dml/replace.xml |  2 +-
 test/parser/src/main/resources/case/dml/select.xml | 14 ++++++++++
 test/parser/src/main/resources/case/dml/update.xml |  2 +-
 .../main/resources/sql/supported/dml/select.xml    |  1 +
 .../case/query-with-cipher/dml/update/update.xml   | 12 ++++----
 18 files changed, 86 insertions(+), 28 deletions(-)

diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptLiteralAssignmentToken.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptLiteralAssignmentToken.java
index ec51595dfc8..f5f5ca8f0f3 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptLiteralAssignmentToken.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptLiteralAssignmentToken.java
@@ -62,6 +62,9 @@ public final class EncryptLiteralAssignmentToken extends 
EncryptAssignmentToken
         }
         
         private String toString(final Object value) {
+            if (null == value) {
+                return "NULL";
+            }
             return value instanceof String ? "'" + value + "'" : 
value.toString();
         }
     }
diff --git 
a/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/FilterableTableScanExecutor.java
 
b/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/FilterableTableScanExecutor.java
index 41a674beccf..e77ced46423 100644
--- 
a/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/FilterableTableScanExecutor.java
+++ 
b/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/FilterableTableScanExecutor.java
@@ -119,8 +119,8 @@ public final class FilterableTableScanExecutor implements 
TableScanExecutor {
     
     @Override
     public Enumerable<Object[]> execute(final ShardingSphereTable table, final 
ScanNodeExecutorContext scanContext) {
-        String databaseName = executorContext.getDatabaseName();
-        String schemaName = executorContext.getSchemaName();
+        String databaseName = executorContext.getDatabaseName().toLowerCase();
+        String schemaName = executorContext.getSchemaName().toLowerCase();
         DatabaseType databaseType = 
DatabaseTypeEngine.getTrunkDatabaseType(optimizerContext.getParserContext(databaseName).getDatabaseType().getType());
         if (databaseType.getSystemSchemas().contains(schemaName)) {
             return executeByShardingSphereData(databaseName, schemaName, 
table);
diff --git 
a/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/TranslatableTableScanExecutor.java
 
b/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/TranslatableTableScanExecutor.java
index 41b0d17d645..41ede214d7b 100644
--- 
a/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/TranslatableTableScanExecutor.java
+++ 
b/kernel/sql-federation/executor/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/TranslatableTableScanExecutor.java
@@ -122,8 +122,8 @@ public final class TranslatableTableScanExecutor implements 
TableScanExecutor {
     
     @Override
     public Enumerable<Object[]> execute(final ShardingSphereTable table, final 
ScanNodeExecutorContext scanContext) {
-        String databaseName = executorContext.getDatabaseName();
-        String schemaName = executorContext.getSchemaName();
+        String databaseName = executorContext.getDatabaseName().toLowerCase();
+        String schemaName = executorContext.getSchemaName().toLowerCase();
         DatabaseType databaseType = 
DatabaseTypeEngine.getTrunkDatabaseType(optimizerContext.getParserContext(databaseName).getDatabaseType().getType());
         SqlString sqlString = createSQLString(table, 
(TranslatableScanNodeExecutorContext) scanContext, 
SQLDialectFactory.getSQLDialect(databaseType));
         // TODO replace sql parse with sql convert
diff --git 
a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/LiteralExpressionConverter.java
 
b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/LiteralExpressionConverter.java
index 9cb28f8a069..dc8543b22a2 100644
--- 
a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/LiteralExpressionConverter.java
+++ 
b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/LiteralExpressionConverter.java
@@ -20,8 +20,8 @@ package 
org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expr
 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.segment.SQLSegmentConverter;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
+import 
org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
 
 import java.util.Optional;
 
@@ -32,11 +32,14 @@ public final class LiteralExpressionConverter implements 
SQLSegmentConverter<Lit
     
     @Override
     public Optional<SqlNode> convert(final LiteralExpressionSegment segment) {
-        if (Integer.class == segment.getLiterals().getClass()) {
+        if (null == segment.getLiterals()) {
+            return Optional.of(SqlLiteral.createNull(SqlParserPos.ZERO));
+        }
+        if (segment.getLiterals() instanceof Integer) {
             return 
Optional.of(SqlLiteral.createExactNumeric(String.valueOf(segment.getLiterals()),
 SqlParserPos.ZERO));
         }
-        if (String.class == segment.getLiterals().getClass()) {
-            return Optional.of(SqlLiteral.createCharString((String) 
segment.getLiterals(), SqlParserPos.ZERO));
+        if (segment.getLiterals() instanceof String) {
+            return 
Optional.of(SqlLiteral.createCharString(String.valueOf(segment.getLiterals()), 
SqlParserPos.ZERO));
         }
         return Optional.empty();
     }
diff --git 
a/sql-parser/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
 
b/sql-parser/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
index 812ae8e85a4..fa14fa9360e 100644
--- 
a/sql-parser/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
+++ 
b/sql-parser/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
@@ -208,6 +208,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.collection.CollectionValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.BooleanLiteralValue;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NullLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.OtherLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
@@ -309,8 +310,7 @@ public abstract class MySQLStatementSQLVisitor extends 
MySQLStatementBaseVisitor
     
     @Override
     public final ASTNode visitNullValueLiterals(final NullValueLiteralsContext 
ctx) {
-        // TODO deal with nullValueLiterals
-        return new OtherLiteralValue(ctx.getText());
+        return new NullLiteralValue(ctx.getText());
     }
     
     @Override
diff --git 
a/sql-parser/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java
 
b/sql-parser/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java
index 135517a6e11..f0c84ebaefa 100644
--- 
a/sql-parser/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java
+++ 
b/sql-parser/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java
@@ -73,6 +73,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlCol
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlExistsFunctionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlForestFunctionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlFunctionContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlNameSpaceStringAsIdentifierContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlNameSpacesClauseContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlParseFunctionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlPiFunctionContext;
@@ -82,7 +83,6 @@ import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlSer
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlTableColumnContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlTableFunctionContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlTableOptionsContext;
-import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlNameSpaceStringAsIdentifierContext;
 import org.apache.shardingsphere.sql.parser.sql.common.enums.AggregationType;
 import org.apache.shardingsphere.sql.parser.sql.common.enums.NullsOrderType;
 import org.apache.shardingsphere.sql.parser.sql.common.enums.OrderDirection;
@@ -134,6 +134,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.value.collection.Collecti
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.keyword.KeywordValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.BooleanLiteralValue;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NullLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.OtherLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
@@ -221,8 +222,7 @@ public abstract class OracleStatementSQLVisitor extends 
OracleStatementBaseVisit
     
     @Override
     public final ASTNode visitNullValueLiterals(final NullValueLiteralsContext 
ctx) {
-        // TODO deal with nullValueLiterals
-        return new OtherLiteralValue(ctx.getText());
+        return new NullLiteralValue(ctx.getText());
     }
     
     @Override
diff --git 
a/sql-parser/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/impl/SQL92StatementSQLVisitor.java
 
b/sql-parser/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/impl/SQL92StatementSQLVisitor.java
index 991816db5d5..f6945e13019 100644
--- 
a/sql-parser/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/impl/SQL92StatementSQLVisitor.java
+++ 
b/sql-parser/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/impl/SQL92StatementSQLVisitor.java
@@ -93,6 +93,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.value.collection.Collecti
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.keyword.KeywordValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.BooleanLiteralValue;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NullLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.OtherLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
@@ -177,8 +178,7 @@ public abstract class SQL92StatementSQLVisitor extends 
SQL92StatementBaseVisitor
     
     @Override
     public final ASTNode visitNullValueLiterals(final NullValueLiteralsContext 
ctx) {
-        // TODO deal with nullValueLiterals
-        return new OtherLiteralValue(ctx.getText());
+        return new NullLiteralValue(ctx.getText());
     }
     
     @Override
diff --git 
a/sql-parser/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerStatementSQLVisitor.java
 
b/sql-parser/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerStatementSQLVisitor.java
index 706d65eb973..ee8e6f1a5b8 100644
--- 
a/sql-parser/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerStatementSQLVisitor.java
+++ 
b/sql-parser/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerStatementSQLVisitor.java
@@ -174,6 +174,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.value.collection.Collecti
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.keyword.KeywordValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.BooleanLiteralValue;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NullLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.OtherLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
@@ -262,8 +263,7 @@ public abstract class SQLServerStatementSQLVisitor extends 
SQLServerStatementBas
     
     @Override
     public final ASTNode visitNullValueLiterals(final NullValueLiteralsContext 
ctx) {
-        // TODO deal with nullValueLiterals
-        return new OtherLiteralValue(ctx.getText());
+        return new NullLiteralValue(ctx.getText());
     }
     
     @Override
diff --git 
a/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
 
b/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
index 7cb80883975..b11ad713e65 100644
--- 
a/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
+++ 
b/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
@@ -41,6 +41,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertState
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.BooleanLiteralValue;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NullLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.OtherLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
@@ -271,6 +272,9 @@ public final class SQLUtil {
         if (astNode instanceof BooleanLiteralValue) {
             return new LiteralExpressionSegment(startIndex, stopIndex, 
((BooleanLiteralValue) astNode).getValue());
         }
+        if (astNode instanceof NullLiteralValue) {
+            return new LiteralExpressionSegment(startIndex, stopIndex, null);
+        }
         if (astNode instanceof OtherLiteralValue) {
             return new CommonExpressionSegment(startIndex, stopIndex, 
((OtherLiteralValue) astNode).getValue());
         }
diff --git 
a/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/value/literal/impl/NullLiteralValue.java
 
b/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/value/literal/impl/NullLiteralValue.java
new file mode 100644
index 00000000000..fed7517c512
--- /dev/null
+++ 
b/sql-parser/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/value/literal/impl/NullLiteralValue.java
@@ -0,0 +1,32 @@
+/*
+ * 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.sql.parser.sql.common.value.literal.impl;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.LiteralValue;
+
+/**
+ * Null literal value.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class NullLiteralValue implements LiteralValue<String> {
+    
+    private final String value;
+}
diff --git 
a/test/optimize/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConverterEngineParameterizedTest.java
 
b/test/optimize/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConverterEngineParameterizedTest.java
index 40c1705973d..387c6fa6d98 100644
--- 
a/test/optimize/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConverterEngineParameterizedTest.java
+++ 
b/test/optimize/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConverterEngineParameterizedTest.java
@@ -125,6 +125,7 @@ public final class SQLNodeConverterEngineParameterizedTest {
         SUPPORTED_SQL_CASE_IDS.add("select_pagination_with_offset_fetch");
         
SUPPORTED_SQL_CASE_IDS.add("select_pagination_with_limit_offset_and_row_count");
         SUPPORTED_SQL_CASE_IDS.add("select_pagination_with_limit_row_count");
+        SUPPORTED_SQL_CASE_IDS.add("select_with_null_keyword_in_projection");
         SUPPORTED_SQL_CASE_IDS.add("select_union");
         SUPPORTED_SQL_CASE_IDS.add("select_union_all");
         SUPPORTED_SQL_CASE_IDS.add("select_union_all_order_by");
diff --git 
a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/asserts/segment/expression/ExpressionAssert.java
 
b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/asserts/segment/expression/ExpressionAssert.java
index 53d63bfa78f..f2b03e7a618 100644
--- 
a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/asserts/segment/expression/ExpressionAssert.java
+++ 
b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/internal/asserts/segment/expression/ExpressionAssert.java
@@ -106,7 +106,7 @@ public final class ExpressionAssert {
             assertNull(assertContext.getText("Actual literal expression should 
not exist."), actual);
         } else {
             assertNotNull(assertContext.getText("Actual literal expression 
should exist."), actual);
-            assertThat(assertContext.getText("Literal assertion error: "), 
actual.getLiterals().toString(), is(expected.getValue()));
+            assertThat(assertContext.getText("Literal assertion error: "), 
String.valueOf(actual.getLiterals()), is(expected.getValue()));
             SQLSegmentAssert.assertIs(assertContext, actual, expected);
         }
     }
diff --git a/test/parser/src/main/resources/case/dml/insert.xml 
b/test/parser/src/main/resources/case/dml/insert.xml
index 6e2a2acfd01..073f94efe87 100644
--- a/test/parser/src/main/resources/case/dml/insert.xml
+++ b/test/parser/src/main/resources/case/dml/insert.xml
@@ -994,7 +994,7 @@
         <values>
             <value>
                 <assignment-value>
-                    <common-expression text="null" start-index="43" 
stop-index="46" />
+                    <literal-expression value="null" start-index="43" 
stop-index="46" />
                 </assignment-value>
             </value>
         </values>
@@ -1847,7 +1847,7 @@
                     <literal-expression value="1.2E+3" start-index="178" 
stop-index="182" />
                 </assignment-value>
                 <assignment-value>
-                    <common-expression text="NULL" start-index="185" 
stop-index="188" />
+                    <literal-expression value="null" start-index="185" 
stop-index="188" />
                 </assignment-value>
             </value>
         </values>
diff --git a/test/parser/src/main/resources/case/dml/replace.xml 
b/test/parser/src/main/resources/case/dml/replace.xml
index 6a919bf881b..ce92a4aa732 100644
--- a/test/parser/src/main/resources/case/dml/replace.xml
+++ b/test/parser/src/main/resources/case/dml/replace.xml
@@ -715,7 +715,7 @@
         <values>
             <value>
                 <assignment-value>
-                    <common-expression text="null" start-index="44" 
stop-index="47" />
+                    <literal-expression value="null" start-index="44" 
stop-index="47" />
                 </assignment-value>
             </value>
         </values>
diff --git a/test/parser/src/main/resources/case/dml/select.xml 
b/test/parser/src/main/resources/case/dml/select.xml
index 990cdcbbb4d..cc07c1d3350 100644
--- a/test/parser/src/main/resources/case/dml/select.xml
+++ b/test/parser/src/main/resources/case/dml/select.xml
@@ -4807,4 +4807,18 @@
             <offset value="3" start-index="37" stop-index="37" />
         </limit>
     </select>
+
+    <select sql-case-id="select_with_null_keyword_in_projection">
+        <projections start-index="7" stop-index="31">
+            <expression-projection text="null" alias="order_id" 
start-index="7" stop-index="22">
+                <expr>
+                    <literal-expression value="null" start-index="7" 
stop-index="10" />
+                </expr>
+            </expression-projection>
+            <column-projection name="item_id" start-index="25" stop-index="31" 
/>
+        </projections>
+        <from>
+            <simple-table name="t_order" start-index="38" stop-index="44" />
+        </from>
+    </select>
 </sql-parser-test-cases>
diff --git a/test/parser/src/main/resources/case/dml/update.xml 
b/test/parser/src/main/resources/case/dml/update.xml
index a83b53f711d..41948346ae1 100644
--- a/test/parser/src/main/resources/case/dml/update.xml
+++ b/test/parser/src/main/resources/case/dml/update.xml
@@ -878,7 +878,7 @@
             <assignment start-index="21" stop-index="41">
                 <column name="commission_pct" start-index="21" stop-index="34" 
/>
                 <assignment-value>
-                    <common-expression text="NULL" start-index="38" 
stop-index="41" />
+                    <literal-expression value="null" start-index="38" 
stop-index="41" />
                 </assignment-value>
             </assignment>
         </set>
diff --git a/test/parser/src/main/resources/sql/supported/dml/select.xml 
b/test/parser/src/main/resources/sql/supported/dml/select.xml
index 83ba13d76b3..196a4dfc9f0 100644
--- a/test/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/parser/src/main/resources/sql/supported/dml/select.xml
@@ -156,4 +156,5 @@
     <sql-case id="select_xmlserialize_function" value="SELECT 
XMLSERIALIZE(DOCUMENT c2 AS BLOB ENCODING 'UTF-8' VERSION 'a' IDENT SIZE = 0 
SHOW DEFAULT) FROM b;" db-types="Oracle" />
     <sql-case id="select_from_xmltable_function" value="SELECT warehouse_name 
warehouse, warehouse2.Water, warehouse2.Rail FROM warehouses, 
XMLTABLE('/Warehouse' PASSING warehouses.warehouse_spec COLUMNS 
&quot;Water&quot; varchar2(6) PATH 'WaterAccess',&quot;Rail&quot; varchar2(6) 
PATH 'RailAccess') warehouse2;" db-types="Oracle" />
     <sql-case id="select_with_offset" value="select * from t_new_order fetch 
next 3 row only;" db-types="openGauss,PostgreSQL" />
+    <sql-case id="select_with_null_keyword_in_projection" value="select null 
as order_id, item_id from t_order" db-types="MySQL" />
 </sql-cases>
diff --git 
a/test/rewrite/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml
 
b/test/rewrite/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml
index ded9abcf1c5..22a6c9de7cf 100644
--- 
a/test/rewrite/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml
+++ 
b/test/rewrite/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml
@@ -66,31 +66,31 @@
     
     <rewrite-assertion id="update_null_to_clear_plain" db-types="MySQL">
         <input sql="UPDATE t_account_bak SET certificate_number = NULL" />
-        <output sql="UPDATE t_account_bak SET certificate_number = NULL" />
+        <output sql="UPDATE t_account_bak SET cipher_certificate_number = 
NULL, assisted_query_certificate_number = NULL, like_query_certificate_number = 
NULL, plain_certificate_number = NULL" />
     </rewrite-assertion>
 
     <rewrite-assertion id="update_null_to_clear_plain_with_multi" 
db-types="MySQL">
         <input sql="UPDATE t_account_bak SET certificate_number = NULL, 
certificate_number = ''" />
-        <output sql="UPDATE t_account_bak SET certificate_number = NULL, 
cipher_certificate_number = 'encrypt_', assisted_query_certificate_number = 
'assisted_query_', like_query_certificate_number = 'like_query_', 
plain_certificate_number = ''" />
+        <output sql="UPDATE t_account_bak SET cipher_certificate_number = 
NULL, assisted_query_certificate_number = NULL, like_query_certificate_number = 
NULL, plain_certificate_number = NULL, cipher_certificate_number = 'encrypt_', 
assisted_query_certificate_number = 'assisted_query_', 
like_query_certificate_number = 'like_query_', plain_certificate_number = ''" />
     </rewrite-assertion>
 
     <rewrite-assertion id="update_null_to_clear_plain_where_is_null" 
db-types="MySQL">
         <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
certificate_number IS NULL" />
-        <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
assisted_query_certificate_number IS NULL" />
+        <output sql="UPDATE t_account_bak SET cipher_certificate_number = 
NULL, assisted_query_certificate_number = NULL, like_query_certificate_number = 
NULL, plain_certificate_number = NULL WHERE assisted_query_certificate_number 
IS NULL" />
     </rewrite-assertion>
 
     <rewrite-assertion 
id="update_null_to_clear_plain_where_is_null_with_multi" db-types="MySQL">
         <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
certificate_number IS NULL AND status = 'OK' AND certificate_number = '111X'" />
-        <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
assisted_query_certificate_number IS NULL AND status = 'OK' AND 
assisted_query_certificate_number = 'assisted_query_111X'" />
+        <output sql="UPDATE t_account_bak SET cipher_certificate_number = 
NULL, assisted_query_certificate_number = NULL, like_query_certificate_number = 
NULL, plain_certificate_number = NULL WHERE assisted_query_certificate_number 
IS NULL AND status = 'OK' AND assisted_query_certificate_number = 
'assisted_query_111X'" />
     </rewrite-assertion>
 
     <rewrite-assertion id="update_null_to_clear_plain_where_is_not_null" 
db-types="MySQL">
         <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
certificate_number IS NOT NULL" />
-        <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
assisted_query_certificate_number IS NOT NULL" />
+        <output sql="UPDATE t_account_bak SET cipher_certificate_number = 
NULL, assisted_query_certificate_number = NULL, like_query_certificate_number = 
NULL, plain_certificate_number = NULL WHERE assisted_query_certificate_number 
IS NOT NULL" />
     </rewrite-assertion>
 
     <rewrite-assertion 
id="update_null_to_clear_plain_where_is_not_null_with_multi" db-types="MySQL">
         <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
certificate_number IS NOT NULL AND status = 'OK' AND certificate_number = 
'111X'" />
-        <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE 
assisted_query_certificate_number IS NOT NULL AND status = 'OK' AND 
assisted_query_certificate_number = 'assisted_query_111X'" />
+        <output sql="UPDATE t_account_bak SET cipher_certificate_number = 
NULL, assisted_query_certificate_number = NULL, like_query_certificate_number = 
NULL, plain_certificate_number = NULL WHERE assisted_query_certificate_number 
IS NOT NULL AND status = 'OK' AND assisted_query_certificate_number = 
'assisted_query_111X'" />
     </rewrite-assertion>
 </rewrite-assertions>

Reply via email to