Jackie-Jiang commented on code in PR #11330:
URL: https://github.com/apache/pinot/pull/11330#discussion_r1293064632


##########
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:
   Can we skip `WHERE` clause for other if branches?
   E.g. `SELECT * FROM myTable AS T1 WHERE col1 = (SELECT col2 FROM T2)`



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