tanmesh commented on code in PR #9263: URL: https://github.com/apache/pinot/pull/9263#discussion_r952042753
########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/Connection.java: ########## @@ -105,6 +108,38 @@ 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 (Exception e) { + LOGGER.info("Caught exception while compiling SQL request: {}, {}", query, e.getMessage()); + throw new PinotClientException("Caught exception while compiling SQL request"); + } + + DataSource dataSource; + + try { + dataSource = pinotQuery.getDataSource(); + } catch (Exception e) { + throw new PinotClientException("Caught exception while extracting DataSource from PinotQuery. DataSource is null."); + } + + String tableName = dataSource.getTableName(); + + if(tableName == null) { Review Comment: Thanks for the suggestion! I have fixed this and added the appropriate test for this scenario. -- 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