amogh-jahagirdar commented on code in PR #9487:
URL: https://github.com/apache/iceberg/pull/9487#discussion_r1462645409


##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -245,13 +270,17 @@ public List<TableIdentifier> listTables(Namespace 
namespace) {
         row ->
             JdbcUtil.stringToTableIdentifier(
                 row.getString(JdbcUtil.TABLE_NAMESPACE), 
row.getString(JdbcUtil.TABLE_NAME)),
-        JdbcUtil.LIST_TABLES_SQL,
+        JdbcUtil.listTablesSql(),
         catalogName,
         JdbcUtil.namespaceToString(namespace));
   }
 
   @Override
   public void renameTable(TableIdentifier from, TableIdentifier to) {
+    if (viewExists(to)) {
+      throw new AlreadyExistsException("Cannot rename %s to %s. View already 
exists", from, to);

Review Comment:
   Nit: I think a shorter exception message would work here. 
   
   ```
   throw new AlreadyExistsException("View %s already exists", to);
   ```



##########
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcViewCatalog.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.jdbc;
+
+import java.util.Map;
+import java.util.UUID;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.view.ViewCatalogTests;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.io.TempDir;
+
+public class TestJdbcViewCatalog extends ViewCatalogTests<JdbcCatalog> {
+
+  private JdbcCatalog catalog;
+
+  @TempDir private java.nio.file.Path tableDir;
+
+  @BeforeEach
+  public void before() {
+    Map<String, String> properties = Maps.newHashMap();
+    properties.put(
+        CatalogProperties.URI,
+        "jdbc:sqlite:file::memory:?ic" + 
UUID.randomUUID().toString().replace("-", ""));
+    properties.put(JdbcCatalog.PROPERTY_PREFIX + "username", "user");
+    properties.put(JdbcCatalog.PROPERTY_PREFIX + "password", "password");
+    properties.put(CatalogProperties.WAREHOUSE_LOCATION, 
tableDir.toAbsolutePath().toString());
+
+    catalog = new JdbcCatalog();
+    catalog.setConf(new Configuration());

Review Comment:
   Nit: Do we actually need to pass in the Hadoop conf to the catalog? I would 
assume everything that's passed in via the `Properties` is sufficient.



-- 
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: issues-unsubscr...@iceberg.apache.org

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


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

Reply via email to