nevzheng commented on code in PR #11959:
URL: https://github.com/apache/gravitino/pull/11959#discussion_r3605013384


##########
catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergCatalog.java:
##########
@@ -68,6 +68,24 @@ public ViewCatalog asViewCatalog() {
     return (ViewCatalog) ops();
   }
 
+  /**
+   * Validate the backend connection at create time only when a {@code 
warehouse} is configured.
+   *
+   * <p>On the {@code rest} backend the {@code warehouse} property is a 
catalog selector forwarded
+   * to the remote Iceberg REST server (via {@code GET 
/v1/config?warehouse=...}), not a storage
+   * location. Resolving it at create time turns an unresolvable value (for 
example a
+   * storage-location-shaped URI mistakenly copied from a hive/jdbc example) 
into a fast, actionable
+   * failure. An omitted {@code warehouse} (the server's default REST catalog) 
needs no resolution,
+   * so creation is not forced to touch the backend in that case.
+   *
+   * @return {@code true} if a non-blank {@code warehouse} is configured, 
{@code false} otherwise.
+   */
+  @Override
+  public boolean shouldValidateConnectionForCreate() {
+    Map<String, String> properties = entity().getProperties();
+    return properties != null && 
StringUtils.isNotBlank(properties.get(IcebergConstants.WAREHOUSE));

Review Comment:
   Following up with the final implementation: create-time validation is now 
enabled only for the Iceberg REST backend when `warehouse` is nonblank. Hive 
and JDBC retain their existing behavior. 
`TestIcebergCatalog#testShouldValidateWarehouseProperty` covers the REST, 
missing/blank warehouse, JDBC, and null-backend cases, and 
`TestCatalogManager#testCreateCatalogValidatesBackendConnection` verifies that 
catalogs which do not opt in skip validation during creation. This addresses 
the scope concern.



-- 
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]

Reply via email to