jackye1995 commented on a change in pull request #3275:
URL: https://github.com/apache/iceberg/pull/3275#discussion_r727346630
##########
File path: core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java
##########
@@ -107,14 +108,27 @@ private void initializeCatalogTables() throws
InterruptedException, SQLException
LOG.trace("Creating database tables (if missing) to store iceberg
catalog");
connections.run(conn -> {
DatabaseMetaData dbMeta = conn.getMetaData();
- ResultSet tableExists = dbMeta.getTables(null, null,
JdbcUtil.CATALOG_TABLE_NAME, null);
+ ResultSet tableExists = dbMeta.getTables(null, null,
JdbcCatalogTable.CATALOG_TABLE_NAME, null);
if (tableExists.next()) {
return true;
}
- LOG.debug("Creating table {} to store iceberg catalog",
JdbcUtil.CATALOG_TABLE_NAME);
- return conn.prepareStatement(JdbcUtil.CREATE_CATALOG_TABLE).execute();
+ LOG.debug("Creating table {} to store iceberg catalog tables",
JdbcCatalogTable.CATALOG_TABLE_NAME);
+ return
conn.prepareStatement(JdbcCatalogTable.CREATE_CATALOG_TABLE).execute();
+ });
+ connections.run(conn -> {
Review comment:
nit: newline after control statement like if/for
##########
File path: core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalogNamespace.java
##########
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+public class JdbcCatalogNamespace {
Review comment:
My current opinion is that there is no need to separate `JdbcUtil` into
`JdbcCatalogNamespace` and `JdbcCatalogTable`. All these static variables can
just continue to live under `JdbcUtil`. That would make this PR much cleaner.
What would be the benefits of separating into 2 classes?
##########
File path: core/src/main/java/org/apache/iceberg/jdbc/JdbcUtil.java
##########
@@ -99,4 +65,26 @@ public static Properties filterAndRemovePrefix(Map<String,
String> properties,
return result;
}
+
+ public static Map<String, String> convertJsonStringToMap(String jsonString) {
Review comment:
I wonder if we can just use `SerializationUtil.serializeToBase64`.
Maybe there is some benefit in using a JSON map for readability purpose. In
that case, use `JsonUtil.mapper()` instead of initializing a mapper here.
##########
File path: core/src/main/java/org/apache/iceberg/jdbc/JdbcUtil.java
##########
@@ -99,4 +65,26 @@ public static Properties filterAndRemovePrefix(Map<String,
String> properties,
return result;
}
+
+ public static Map<String, String> convertJsonStringToMap(String jsonString) {
+ Map<String, String> resultMap;
+ try {
+ resultMap = objectMapper.readValue(
+ jsonString, new TypeReference<HashMap<String, String>>() {
+ });
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
Review comment:
throw new UncheckedIOException(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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]