strongduanmu commented on code in PR #29702:
URL: https://github.com/apache/shardingsphere/pull/29702#discussion_r1451520719


##########
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/hint/WithTableHintClauseAssert.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.test.it.sql.parser.internal.asserts.segment.hint;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.segment.sqlserver.hint.TableHintLimitedSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.segment.sqlserver.hint.WithTableHintSegment;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.SQLSegmentAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.hint.ExpectedTableHint;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.hint.ExpectedWithTableHintClause;
+import org.hamcrest.CoreMatchers;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * With table hint clause assert.
+ **/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class WithTableHintClauseAssert {
+    
+    /**
+     * Assert actual with table hint segment is correct with expected table 
hint clause.
+     *
+     * @param assertContext assert context
+     * @param actual        actual with table hint segment
+     * @param expected      expected with table hint clause
+     */
+    public static void assertIs(final SQLCaseAssertContext assertContext, 
final WithTableHintSegment actual, final ExpectedWithTableHintClause expected) {
+        if (null == expected.getTableHint()) {
+            assertThat(assertContext.getText("with table hint clause  
assertion error: "), actual.getTableHintLimitedSegments().size(), 
CoreMatchers.is(expected.getTableHint().size()));
+        } else {
+            int count = 0;
+            for (TableHintLimitedSegment tableHintLimitedSegment : 
actual.getTableHintLimitedSegments()) {

Review Comment:
   Please use each to replace tableHintLimitedSegment.



##########
parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java:
##########
@@ -942,11 +945,34 @@ public ASTNode visitInsert(final InsertContext ctx) {
         if (null != ctx.withClause()) {
             result.setWithSegment((WithSegment) visit(ctx.withClause()));
         }
+        if (null != ctx.withTableHint()) {
+            result.setWithTableHintSegment((WithTableHintSegment) 
visit(ctx.withTableHint()));
+        }
         result.setTable((SimpleTableSegment) visit(ctx.tableName()));
         result.addParameterMarkerSegments(getParameterMarkerSegments());
         return result;
     }
     
+    @Override
+    public ASTNode visitWithTableHint(final WithTableHintContext ctx) {
+        WithTableHintSegment withTableHintSegment = new 
WithTableHintSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex());
+        if (null != ctx.tableHintLimited()) {
+            Collection<TableHintLimitedSegment> tableHintLimitedSegments = new 
LinkedList<>();
+            for (TableHintLimitedContext tableHintLimitedContext : 
ctx.tableHintLimited()) {

Review Comment:
   Please use each to replace tableHintLimitedContext.



##########
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/hint/WithTableHintClauseAssert.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.test.it.sql.parser.internal.asserts.segment.hint;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.segment.sqlserver.hint.TableHintLimitedSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.segment.sqlserver.hint.WithTableHintSegment;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.SQLSegmentAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.hint.ExpectedTableHint;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.hint.ExpectedWithTableHintClause;
+import org.hamcrest.CoreMatchers;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * With table hint clause assert.
+ **/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class WithTableHintClauseAssert {
+    
+    /**
+     * Assert actual with table hint segment is correct with expected table 
hint clause.
+     *
+     * @param assertContext assert context
+     * @param actual        actual with table hint segment

Review Comment:
   Please just use one blank after param.



##########
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/hint/WithTableHintClauseAssert.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.test.it.sql.parser.internal.asserts.segment.hint;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.segment.sqlserver.hint.TableHintLimitedSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.segment.sqlserver.hint.WithTableHintSegment;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.SQLSegmentAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.hint.ExpectedTableHint;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.hint.ExpectedWithTableHintClause;
+import org.hamcrest.CoreMatchers;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * With table hint clause assert.
+ **/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class WithTableHintClauseAssert {
+    
+    /**
+     * Assert actual with table hint segment is correct with expected table 
hint clause.
+     *
+     * @param assertContext assert context
+     * @param actual        actual with table hint segment
+     * @param expected      expected with table hint clause
+     */
+    public static void assertIs(final SQLCaseAssertContext assertContext, 
final WithTableHintSegment actual, final ExpectedWithTableHintClause expected) {
+        if (null == expected.getTableHint()) {
+            assertThat(assertContext.getText("with table hint clause  
assertion error: "), actual.getTableHintLimitedSegments().size(), 
CoreMatchers.is(expected.getTableHint().size()));
+        } else {
+            int count = 0;
+            for (TableHintLimitedSegment tableHintLimitedSegment : 
actual.getTableHintLimitedSegments()) {
+                assertTableHint(assertContext, tableHintLimitedSegment, 
expected.getTableHint().get(count));
+                count++;
+            }
+        }
+        SQLSegmentAssert.assertIs(assertContext, actual, expected);
+    }
+    
+    /**
+     * Assert table hint.
+     *
+     * @param assertContext assert context
+     * @param actual        actual table hint segment

Review Comment:
   Please just use one blank after param.



##########
parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java:
##########
@@ -942,11 +945,34 @@ public ASTNode visitInsert(final InsertContext ctx) {
         if (null != ctx.withClause()) {
             result.setWithSegment((WithSegment) visit(ctx.withClause()));
         }
+        if (null != ctx.withTableHint()) {
+            result.setWithTableHintSegment((WithTableHintSegment) 
visit(ctx.withTableHint()));
+        }
         result.setTable((SimpleTableSegment) visit(ctx.tableName()));
         result.addParameterMarkerSegments(getParameterMarkerSegments());
         return result;
     }
     
+    @Override
+    public ASTNode visitWithTableHint(final WithTableHintContext ctx) {
+        WithTableHintSegment withTableHintSegment = new 
WithTableHintSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex());
+        if (null != ctx.tableHintLimited()) {
+            Collection<TableHintLimitedSegment> tableHintLimitedSegments = new 
LinkedList<>();
+            for (TableHintLimitedContext tableHintLimitedContext : 
ctx.tableHintLimited()) {
+                tableHintLimitedSegments.add((TableHintLimitedSegment) 
visit(tableHintLimitedContext));
+            }
+            
withTableHintSegment.getTableHintLimitedSegments().addAll(tableHintLimitedSegments);
+        }
+        return withTableHintSegment;

Review Comment:
   Please rename it to result.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to