simarjeetss commented on code in PR #4201:
URL: https://github.com/apache/gravitino/pull/4201#discussion_r1683404019
##########
trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/CatalogRegister.java:
##########
@@ -171,33 +171,34 @@ public void registerCatalog(String name, GravitinoCatalog
catalog) {
}
private boolean checkCatalogExist(String name) {
- String showCatalogCommand = String.format("SHOW CATALOGS like '%s'", name);
- Exception failedException = null;
- try {
- int retries = EXECUTE_QUERY_MAX_RETRIES;
- while (retries-- > 0) {
- try (Statement statement = connection.createStatement()) {
- // check the catalog is already created
- statement.execute(showCatalogCommand);
- ResultSet rs = statement.getResultSet();
- while (rs.next()) {
- String catalogName = rs.getString(1);
- if (catalogName.equals(name) || catalogName.equals("\"" + name +
"\"")) {
- return true;
- }
+ String showCatalogCommand = String.format("SHOW CATALOGS LIKE '%s'", name);
+ long endTime = System.currentTimeMillis() + EXECUTE_QUERY_TIMEOUT_MS;
+
+ do {
+ try (Statement statement = connection.createStatement();
+ ResultSet rs = statement.executeQuery(showCatalogCommand)) {
+
+ while (rs.next()) {
+ if (name.equalsIgnoreCase(rs.getString(1).replace("\"", ""))) {
+ return true;
}
- return false;
- } catch (Exception e) {
- failedException = e;
- LOG.warn("Execute command failed: {}, ", showCatalogCommand, e);
- Thread.sleep(EXECUTE_QUERY_BACKOFF_TIME_SECOND * 1000);
+ }
+ return false;
+ } catch (SQLException e) {
Review Comment:
Actually it should be **Exception e ** insteadof **SQLException**. Shall I
make this change?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]