-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
(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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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);
+ }
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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?
I think this PR should not just partly fix the issue for views, but also for tables and namespaces. |
Closing this one in favor of #12314 |
No description provided.