924060929 commented on code in PR #10415:
URL: https://github.com/apache/doris/pull/10415#discussion_r910584924


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -114,35 +168,60 @@ public Slot visitUnboundSlot(UnboundSlot unboundSlot, 
Void context) {
 
         @Override
         public Expression visitUnboundStar(UnboundStar unboundStar, Void 
context) {
+            if (!isProjection) {
+                throw new AnalysisException("UnboundStar must exists in 
Projection");
+            }
             List<String> qualifier = unboundStar.getQualifier();
-            List<Slot> boundSlots = Lists.newArrayList();
             switch (qualifier.size()) {
                 case 0: // select *
-                    boundSlots.addAll(boundSlots);
-                    break;
+                    return new BoundStar(boundSlots);
                 case 1: // select table.*
-                    analyzeBoundSlots(qualifier, context);
-                    break;
                 case 2: // select db.table.*
-                    analyzeBoundSlots(qualifier, context);
-                    break;
+                    return bindQualifiedStar(qualifier, context);
                 default:
                     throw new AnalysisException("Not supported qualifier: "
                         + StringUtils.join(qualifier, "."));
             }
-            return null;
         }
 
-        private void analyzeBoundSlots(List<String> qualifier, Void context) {
-            this.boundSlots.stream()
-                    .forEach(slot ->
-                        boundSlots.add(visitUnboundSlot(new UnboundSlot(
-                            ImmutableList.<String>builder()
-                                .addAll(qualifier)
-                                .add(slot.getName())
-                                .build()
-                        ), context))
-                    );
+        private BoundStar bindQualifiedStar(List<String> qualifierStar, Void 
context) {
+            List<Slot> slots = boundSlots.stream().filter(boundSlot -> {
+                switch (qualifierStar.size()) {
+                    // table.*
+                    case 1:
+                        List<String> boundSlotQualifier = 
boundSlot.getQualifier();
+                        switch (boundSlotQualifier.size()) {
+                            // bound slot is `column` and no qualified
+                            case 0: return false;
+                            case 1: // bound slot is `table`.`column`
+                                return 
qualifierStar.get(0).equalsIgnoreCase(boundSlotQualifier.get(0));
+                            case 2:// bound slot is `db`.`table`.`column`
+                                return 
qualifierStar.get(0).equalsIgnoreCase(boundSlotQualifier.get(1));

Review Comment:
   > what will happen?
   
   sparksql will select all column in the db.t1 and the t1.
   doris legacy analyzer will throw exception: Column 'xxx' in is ambiguous.
   
   > what should happen?
   
   compatible with previous behavior and throw exception.
   
   ---
   I will add a fixme comment
   
   



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/GroupExpressionMatching.java:
##########
@@ -102,9 +104,12 @@ public GroupExpressionIterator(Pattern<Plan, Plan> 
pattern, GroupExpression grou
                     Group childGroup = groupExpression.child(i);
                     List<Plan> childrenPlan = matchingChildGroup(pattern, 
childGroup, i);
                     childrenPlans.add(childrenPlan);
+                    if (childrenPlans.isEmpty()) {

Review Comment:
   I add a ut



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to