xiaokang commented on code in PR #26749:
URL: https://github.com/apache/doris/pull/26749#discussion_r1403933281


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java:
##########
@@ -1004,11 +1011,49 @@ public SlotDescriptor registerColumnRef(TableName 
tblName, String colName) throw
                                                 newTblName == null ? 
d.getTable().getName() : newTblName.toString());
         }
 
+        LOG.debug("register column ref table {}, colName {}, col {}", tblName, 
colName, col.toSql());
+        if (col.getType().isVariantType() || (subColNames != null && 
!subColNames.isEmpty())) {
+            if (!col.getType().isVariantType()) {
+                
ErrorReport.reportAnalysisException(ErrorCode.ERR_ILLEGAL_COLUMN_REFERENCE_ERROR,
+                        Joiner.on(".").join(tblName.getTbl(), colName));
+            }
+            if (subColNames == null) {
+                // Root
+                subColNames = new ArrayList<String>();
+            }
+            String key = d.getAlias() + "." + col.getName();
+            if (subColumnSlotRefMap.get(key) == null) {
+                subColumnSlotRefMap.put(key, Maps.newTreeMap(
+                    new Comparator<List<String>>() {
+                        public int compare(List<String> lst1, List<String> 
lst2) {
+                            String str1 = String.join(".", lst1);
+                            String str2 = String.join(".", lst2);
+                            return str1.compareTo(str2);
+                        }
+                    }));
+            }
+            SlotDescriptor result = 
subColumnSlotRefMap.get(key).get(subColNames);
+            if (result != null) {
+                // avoid duplicate slots
+                return result;
+            }
+            result = globalState.descTbl.addSlotDescriptor(d);
+            LOG.debug("register slot descriptor {}", result);
+            result.setSubColLables(subColNames);
+            result.setColumn(col);
+            if (!subColNames.isEmpty()) {
+                result.setMaterializedColumnName(col.getName() + "." + 
String.join(".", subColNames));
+            }
+            result.setIsMaterialized(true);
+            result.setIsNullable(col.isAllowNull());
+            subColumnSlotRefMap.get(key).put(subColNames, result);

Review Comment:
   unify to subColumnSlotRefMap



-- 
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