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

duanzhengqiang 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 adb9cfb795b Refactor ColumnSegmentBinder. (#33365)
adb9cfb795b is described below

commit adb9cfb795b4bcf737c7b0d87c1fa2bbdf672408
Author: Cong Hu <[email protected]>
AuthorDate: Wed Oct 23 16:38:11 2024 +0800

    Refactor ColumnSegmentBinder. (#33365)
---
 .../segment/expression/type/ColumnSegmentBinder.java   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/ColumnSegmentBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/ColumnSegmentBinder.java
index ca8f52b8572..b7c563bf8c0 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/ColumnSegmentBinder.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/ColumnSegmentBinder.java
@@ -136,14 +136,15 @@ public final class ColumnSegmentBinder {
         boolean isFindInputColumn = false;
         for (TableSegmentBinderContext each : tableBinderContexts) {
             Optional<ProjectionSegment> projectionSegment = 
each.findProjectionSegmentByColumnLabel(segment.getIdentifier().getValue());
-            if (projectionSegment.isPresent() && projectionSegment.get() 
instanceof ColumnProjectionSegment) {
+            if (!projectionSegment.isPresent()) {
+                continue;
+            }
+            if (projectionSegment.get() instanceof ColumnProjectionSegment) {
                 ShardingSpherePreconditions.checkState(null == result,
                         () -> new 
AmbiguousColumnException(segment.getExpression(), 
SEGMENT_TYPE_MESSAGES.getOrDefault(parentSegmentType, 
UNKNOWN_SEGMENT_TYPE_MESSAGE)));
-                result = ((ColumnProjectionSegment) 
projectionSegment.get()).getColumn();
-            }
-            if (!isFindInputColumn && projectionSegment.isPresent()) {
-                isFindInputColumn = true;
             }
+            result = getColumnSegment(projectionSegment.get());
+            isFindInputColumn = true;
         }
         if (!isFindInputColumn) {
             Optional<ProjectionSegment> projectionSegment = 
findInputColumnSegmentFromOuterTable(segment, outerTableBinderContexts);
@@ -172,6 +173,13 @@ public final class ColumnSegmentBinder {
         return Optional.ofNullable(result);
     }
     
+    private static ColumnSegment getColumnSegment(final ProjectionSegment 
projectionSegment) {
+        if (projectionSegment instanceof ColumnProjectionSegment) {
+            return ((ColumnProjectionSegment) projectionSegment).getColumn();
+        }
+        return null;
+    }
+    
     private static Optional<ColumnSegment> 
findInputColumnSegmentByPivotColumns(final ColumnSegment segment, final 
Collection<String> pivotColumnNames) {
         if (pivotColumnNames.isEmpty()) {
             return Optional.empty();

Reply via email to