rdblue commented on a change in pull request #3275:
URL: https://github.com/apache/iceberg/pull/3275#discussion_r735009363
##########
File path: core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java
##########
@@ -252,8 +267,34 @@ public void setConf(Configuration conf) {
@Override
public void createNamespace(Namespace namespace, Map<String, String>
metadata) {
- throw new UnsupportedOperationException("Cannot create namespace " +
namespace +
- ": createNamespace is not supported");
+ if (namespaceExists(namespace)) {
+ throw new AlreadyExistsException("Namespace already exists: %s",
namespace);
+ }
+
+ String namespaceName = JdbcUtil.namespaceToString(namespace);
+ try {
+ int insertRecord = connections.run(conn -> {
+ try (PreparedStatement sql =
conn.prepareStatement(JdbcUtil.DO_COMMIT_CREATE_NAMESPACE_SQL)) {
+ sql.setString(1, catalogName);
+ sql.setString(2, namespaceName);
+ sql.setString(3, "createdAt");
+ sql.setString(4, Instant.now().toString());
Review comment:
I don't think it is a good idea to use a `createdAt` property because
the namespace can exist without any properties if tables exist. Instead, this
should just reject creating a namespace without any metadata. So if metadata is
empty or null this fails.
This also needs to insert the metadata into the properties table.
--
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]