xiangfu0 commented on code in PR #11330:
URL: https://github.com/apache/pinot/pull/11330#discussion_r1293090335


##########
pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java:
##########
@@ -290,4 +303,90 @@ public static Map<String, String> 
getOptionsFromJson(JsonNode request, String op
   public static Map<String, String> getOptionsFromString(String optionStr) {
     return 
Splitter.on(';').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(optionStr);
   }
+
+  public static Set<String> getTableNames(SqlNode sqlNode) {
+    Set<String> tableNames = new HashSet<>();
+    if (sqlNode instanceof SqlSelect) {
+      // Handle SqlSelect query
+      SqlNode fromNode = ((SqlSelect) sqlNode).getFrom();
+      if ((fromNode instanceof SqlBasicCall)
+          && (((SqlBasicCall) fromNode).getOperator() instanceof 
SqlAsOperator)) {
+        tableNames.addAll(getTableNames(((SqlBasicCall) 
fromNode).getOperandList().get(0)));
+      } else if (fromNode instanceof SqlIdentifier) {
+        tableNames.add(getTableName((SqlIdentifier) fromNode));
+        tableNames.addAll(getTableNames(((SqlSelect) sqlNode).getWhere()));

Review Comment:
   Need to check recursively. This Where SqlNode is a SqlBasicCall, with 
SqlSelect inside.
   See more examples in tests:
   
https://github.com/apache/pinot/pull/11330/files#diff-a4bccc2639d28b1ed4eeb105200ce6da89b1f53876909863134a7084c1aa2b8cR95
   and 
   
https://github.com/apache/pinot/pull/11330/files#diff-a4bccc2639d28b1ed4eeb105200ce6da89b1f53876909863134a7084c1aa2b8cR147
   



-- 
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...@pinot.apache.org

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


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

Reply via email to