imay commented on a change in pull request #1629: Enable parsing columns from 
file path for Broker Load (#1582)
URL: https://github.com/apache/incubator-doris/pull/1629#discussion_r313234607
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/planner/BrokerScanNode.java
 ##########
 @@ -696,9 +699,40 @@ private TBrokerRangeDesc createBrokerRangeDesc(long 
curFileOffset, TBrokerFileSt
         rangeDesc.setStart_offset(curFileOffset);
         rangeDesc.setSize(rangeBytes);
         rangeDesc.setFile_size(fileStatus.size);
+        rangeDesc.setColumns_from_path(columnsFromPath);
         return rangeDesc;
     }
 
+    private Map<String, String> parseColumnsFromPath(String filePath, 
List<String> columnsFromPath) throws UserException {
+        if (columnsFromPath == null || columnsFromPath.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        String[] strings = filePath.split("/");
+        Map<String, String> columns = new HashMap<>();
+        for (int i = strings.length - 1; i >= 0; i--) {
+            String str = strings[i];
+            if (str == null || str.isEmpty() || !str.contains("=")) {
+                continue;
+            }
+            String[] pair = str.split("=");
+            if (pair.length != 2) {
+                continue;
+            }
+            if (!columnsFromPath.contains(pair[0])) {
+                continue;
+            }
+            columns.put(pair[0], pair[1]);
+            if (columns.size() > columnsFromPath.size()) {
+                break;
+            }
+        }
+        if (columns.size() != columnsFromPath.size()) {
+            throw new UserException("Fail to parse columnsFromPath, expected: 
" + columnsFromPath + ", filePath: " + filePath);
+        }
+        LOG.info("columns from path: " + columns + ", filePath: " + filePath);
 
 Review comment:
   You should remove this log

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to