Jackie-Jiang commented on code in PR #9263: URL: https://github.com/apache/pinot/pull/9263#discussion_r952969869
########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/Connection.java: ########## @@ -105,6 +108,29 @@ public ResultSetGroup execute(Request request) return execute(null, request); } + /** + * Extract tableName from the given query + * @param query + * @return tableName + * @throws PinotClientException + */ + public String getTableNameFromQuery(String query) { Review Comment: ```suggestion @Nullable public String getTableNameFromQuery(String query) { ``` ########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/Connection.java: ########## @@ -105,6 +108,29 @@ public ResultSetGroup execute(Request request) return execute(null, request); } + /** + * Extract tableName from the given query + * @param query + * @return tableName + * @throws PinotClientException + */ + public String getTableNameFromQuery(String query) { + PinotQuery pinotQuery; + + try { + pinotQuery = CalciteSqlParser.compileToPinotQuery(query); + } catch (PinotClientException e) { + LOGGER.error("Caught exception while compiling SQL request: {}, {}", query, e.getMessage()); Review Comment: We don't want to log an error here because this is most likely a bad query. Suggest not logging because user can get the `PinotClientException` ########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/Connection.java: ########## @@ -105,6 +108,29 @@ public ResultSetGroup execute(Request request) return execute(null, request); } + /** + * Extract tableName from the given query + * @param query + * @return tableName + * @throws PinotClientException + */ + public String getTableNameFromQuery(String query) { + PinotQuery pinotQuery; + + try { + pinotQuery = CalciteSqlParser.compileToPinotQuery(query); + } catch (PinotClientException e) { + LOGGER.error("Caught exception while compiling SQL request: {}, {}", query, e.getMessage()); + throw new PinotClientException("Caught exception while compiling SQL request"); + } + + if(pinotQuery.getDataSource() != null) { Review Comment: (code format) Please reformat the code with [Pinot Style](https://docs.pinot.apache.org/developers/developers-and-contributors/code-setup?q=pinot+style#intellij) ########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/Connection.java: ########## @@ -105,6 +108,29 @@ public ResultSetGroup execute(Request request) return execute(null, request); } + /** + * Extract tableName from the given query + * @param query + * @return tableName + * @throws PinotClientException + */ + public String getTableNameFromQuery(String query) { + PinotQuery pinotQuery; + + try { + pinotQuery = CalciteSqlParser.compileToPinotQuery(query); + } catch (PinotClientException e) { Review Comment: ```suggestion } catch (Exception e) { ``` -- 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