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

chengzhang 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 46f32355eaa Remove wrong owner set for 
CommonTableExpressionSegmentBinder (#34628)
46f32355eaa is described below

commit 46f32355eaada8bcf27e66492f16f384124afecf
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Tue Feb 11 11:53:11 2025 +0800

    Remove wrong owner set for CommonTableExpressionSegmentBinder (#34628)
    
    * Remove wrong owner set for CommonTableExpressionSegmentBinder
    
    * fix sql bind
---
 .../dml/with/CommonTableExpressionSegmentBinder.java   | 18 +++++++-----------
 test/it/binder/src/test/resources/cases/dml/select.xml | 10 ----------
 2 files changed, 7 insertions(+), 21 deletions(-)

diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/with/CommonTableExpressionSegmentBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/with/CommonTableExpressionSegmentBinder.java
index 615447e1c01..e9402bcf7f0 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/with/CommonTableExpressionSegmentBinder.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/with/CommonTableExpressionSegmentBinder.java
@@ -21,11 +21,6 @@ import com.cedarsoftware.util.CaseInsensitiveMap;
 import com.cedarsoftware.util.CaseInsensitiveMap.CaseInsensitiveString;
 import com.google.common.base.Strings;
 import com.google.common.collect.LinkedHashMultimap;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Optional;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.infra.binder.engine.segment.SegmentType;
@@ -43,12 +38,17 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item.Colu
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item.ExpressionProjectionSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item.ProjectionSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item.ShorthandProjectionSegment;
-import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.ColumnSegmentBoundInfo;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SubqueryTableSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
 
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Optional;
+
 /**
  * Common table expression segment binder.
  */
@@ -98,11 +98,7 @@ public final class CommonTableExpressionSegmentBinder {
         } else {
             Collection<ProjectionSegment> projectionSegments = new 
LinkedList<>();
             bindWithColumns(commonTableExpressionSegment.getColumns(), 
commonTableExpressionSegment);
-            commonTableExpressionSegment.getColumns().forEach(each -> {
-                ColumnProjectionSegment columnProjectionSegment = new 
ColumnProjectionSegment(each);
-                columnProjectionSegment.getColumn().setOwner(new 
OwnerSegment(0, 0, 
commonTableExpressionSegment.getAliasSegment().getIdentifier()));
-                projectionSegments.add(columnProjectionSegment);
-            });
+            commonTableExpressionSegment.getColumns().forEach(each -> 
projectionSegments.add(new ColumnProjectionSegment(each)));
             return new SimpleTableSegmentBinderContext(projectionSegments);
         }
     }
diff --git a/test/it/binder/src/test/resources/cases/dml/select.xml 
b/test/it/binder/src/test/resources/cases/dml/select.xml
index 502856d5933..40a147d6790 100644
--- a/test/it/binder/src/test/resources/cases/dml/select.xml
+++ b/test/it/binder/src/test/resources/cases/dml/select.xml
@@ -328,7 +328,6 @@
                     </select>
                 </subquery-expression>
                 <column name="status" start-index="10" stop-index="15" >
-                    <owner name="cte1" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -337,7 +336,6 @@
                     </column-bound>
                 </column>
                 <column name="user_id" start-index="18" stop-index="24" >
-                    <owner name="cte1" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -378,7 +376,6 @@
                     </select>
                 </subquery-expression>
                 <column name="user_id" start-index="76" stop-index="82" >
-                    <owner name="cte2" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -387,7 +384,6 @@
                     </column-bound>
                 </column>
                 <column name="item_id" start-index="85" stop-index="91" >
-                    <owner name="cte2" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -558,7 +554,6 @@
                     </select>
                 </subquery-expression>
                 <column name="col1" start-index="18" stop-index="21">
-                    <owner name="t_order_tmp" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -567,7 +562,6 @@
                     </column-bound>
                 </column>
                 <column name="col2" start-index="24" stop-index="27">
-                    <owner name="t_order_tmp" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -576,7 +570,6 @@
                     </column-bound>
                 </column>
                 <column name="col3" start-index="30" stop-index="33">
-                    <owner name="t_order_tmp" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -585,7 +578,6 @@
                     </column-bound>
                 </column>
                 <column name="col4" start-index="36" stop-index="39">
-                    <owner name="t_order_tmp" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -594,7 +586,6 @@
                     </column-bound>
                 </column>
                 <column name="col5" start-index="42" stop-index="45">
-                    <owner name="t_order_tmp" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />
@@ -603,7 +594,6 @@
                     </column-bound>
                 </column>
                 <column name="col6" start-index="48" stop-index="51">
-                    <owner name="t_order_tmp" start-index="0" stop-index="0" />
                     <column-bound>
                         <original-database name="foo_db_1" />
                         <original-schema name="foo_db_1" />

Reply via email to