Skip to content

Commit

Permalink
fix alter table case fail in RESTCatalogMockServerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-024 committed Jan 8, 2025
1 parent aafa477 commit d6039fb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.paimon.rest.exceptions.RESTException;
import org.apache.paimon.rest.exceptions.ServiceFailureException;
import org.apache.paimon.rest.exceptions.ServiceUnavailableException;
import org.apache.paimon.rest.exceptions.UnsupportedOperationException;
import org.apache.paimon.rest.responses.ErrorResponse;

/** Default error handler. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.paimon.rest.exceptions.BadRequestException;
import org.apache.paimon.rest.exceptions.ForbiddenException;
import org.apache.paimon.rest.exceptions.NoSuchResourceException;
import org.apache.paimon.rest.exceptions.ServiceFailureException;
import org.apache.paimon.rest.requests.AlterDatabaseRequest;
import org.apache.paimon.rest.requests.AlterTableRequest;
import org.apache.paimon.rest.requests.CreateDatabaseRequest;
Expand Down Expand Up @@ -367,6 +368,10 @@ public void alterTable(
throw new ColumnAlreadyExistException(identifier, e.resourceName());
} catch (ForbiddenException e) {
throw new TableNoPermissionException(identifier, e);
} catch (org.apache.paimon.rest.exceptions.UnsupportedOperationException e) {
throw new UnsupportedOperationException(e.getMessage());
} catch (ServiceFailureException e) {
throw new IllegalStateException(e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.paimon.rest.exceptions;

/** Exception thrown on HTTP 501 - UnsupportedOperationException. */
public class UnsupportedOperationException extends RESTException {
public UnsupportedOperationException(String message, Object... args) {
super(String.format(message, args));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
new ErrorResponse(
null, null, e.getCause().getCause().getMessage(), 400);
return mockResponse(response, 400);
} else if (e instanceof UnsupportedOperationException) {
response = new ErrorResponse(null, null, e.getMessage(), 501);
return mockResponse(response, 501);
} else if (e instanceof IllegalStateException) {
response = new ErrorResponse(null, null, e.getMessage(), 500);
return mockResponse(response, 500);
}
return new MockResponse().setResponseCode(500);
}
Expand Down Expand Up @@ -185,7 +191,7 @@ private static MockResponse databaseApiHandler(
response = new GetDatabaseResponse(database.name(), database.options());
return mockResponse(response, 200);
} else if (request.getMethod().equals("DELETE")) {
catalog.dropDatabase(databaseName, true, false);
catalog.dropDatabase(databaseName, true, true);
return new MockResponse().setResponseCode(200);
}
return new MockResponse().setResponseCode(404);
Expand Down

0 comments on commit d6039fb

Please sign in to comment.