Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE: return false when view exists endpoint isn't supported #12259

Closed
wants to merge 1 commit into from

Conversation

danielcweeks
Copy link
Contributor

No description provided.

@danielcweeks danielcweeks requested a review from nastra February 13, 2025 20:55
@github-actions github-actions bot added the core label Feb 13, 2025
@danielcweeks
Copy link
Contributor Author

(cc @ajreid21)

@@ -1239,7 +1239,9 @@ public List<TableIdentifier> listViews(SessionContext context, Namespace namespa

@Override
public boolean viewExists(SessionContext context, TableIdentifier identifier) {
Endpoint.check(endpoints, Endpoint.V1_VIEW_EXISTS);
if (!endpoints.contains(Endpoint.V1_VIEW_EXISTS)) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't the previous behavior to attempt to load the view if the HEAD request is not supported? I think it would be safer to check V1_LOAD_VIEW and use that if it is supported before returning false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might actually need to fall back to loading the view as we did previously. Also btw the same issue applies for namespaceExists and tableExists as those three are all now doing a HEAD request. We might need something like

--- a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
+++ b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
@@ -444,12 +444,14 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog

   @Override
   public boolean tableExists(SessionContext context, TableIdentifier identifier) {
-    Endpoint.check(endpoints, Endpoint.V1_TABLE_EXISTS);
-
     try {
       checkIdentifierIsValid(identifier);
-      client.head(paths.table(identifier), headers(context), ErrorHandlers.tableErrorHandler());
-      return true;
+      if (endpoints.contains(Endpoint.V1_TABLE_EXISTS)) {
+        client.head(paths.table(identifier), headers(context), ErrorHandlers.tableErrorHandler());
+        return true;
+      } else {
+        return super.tableExists(context, identifier);
+      }
     } catch (NoSuchTableException e) {
       return false;
     }
@@ -665,13 +667,15 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog

   @Override
   public boolean namespaceExists(SessionContext context, Namespace namespace) {
-    Endpoint.check(endpoints, Endpoint.V1_NAMESPACE_EXISTS);
-
     try {
       checkNamespaceIsValid(namespace);
-      client.head(
-          paths.namespace(namespace), headers(context), ErrorHandlers.namespaceErrorHandler());
-      return true;
+      if (endpoints.contains(Endpoint.V1_NAMESPACE_EXISTS)) {
+        client.head(
+            paths.namespace(namespace), headers(context), ErrorHandlers.namespaceErrorHandler());
+        return true;
+      } else {
+        return super.namespaceExists(context, namespace);
+      }
     } catch (NoSuchNamespaceException e) {
       return false;
     }
@@ -1239,12 +1243,14 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog

   @Override
   public boolean viewExists(SessionContext context, TableIdentifier identifier) {
-    Endpoint.check(endpoints, Endpoint.V1_VIEW_EXISTS);
-
     try {
       checkViewIdentifierIsValid(identifier);
-      client.head(paths.view(identifier), headers(context), ErrorHandlers.viewErrorHandler());
-      return true;
+      if (endpoints.contains(Endpoint.V1_VIEW_EXISTS)) {
+        client.head(paths.view(identifier), headers(context), ErrorHandlers.viewErrorHandler());
+        return true;
+      } else {
+        return super.viewExists(context, identifier);
+      }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some inconsistency about how we're handling this. The listViews takes the same approach as what I have here, which also aligns with our DEFAULT_ENDPOINTS, so it's strange that it would call load view, but list view would return nothing.

Copy link
Contributor

@ebyhr ebyhr Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for fallback to older logic as @nastra suggested. I sent #12294 with some tests.

I decided to skip Iceberg 1.8.0 in Tirno due to this endpoint's issue and S3 strong integrity checksum issue #12264.

Copy link
Member

@ajantha-bhat ajantha-bhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add the testcase in TCK?
Compatibility suite was suppose to catch this?

@snazy
Copy link
Member

snazy commented Feb 17, 2025

I think this PR should not just partly fix the issue for views, but also for tables and namespaces.

@nastra
Copy link
Contributor

nastra commented Feb 19, 2025

Closing this one in favor of #12314

@nastra nastra closed this Feb 19, 2025
@nastra nastra removed this from the Iceberg 1.8.1 milestone Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants