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

[#2434] Improvement: if DropXXX success, return true, if not exists return false #3222

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

charliecheng630
Copy link
Contributor

What changes were proposed in this pull request?

When dropping the XXX(Metalake/Catalog/Schema/Table/Fileset/Partition/Topic), if the XXX does not exist, then return false.

Why are the changes needed?

a clear drop behavior of return value and exception thrown.

Fix: #2434

Does this PR introduce any user-facing change?

No

How was this patch tested?

ITs and UTs

@jerryshao
Copy link
Collaborator

@mchades would you please help to review this?

@mchades
Copy link
Contributor

mchades commented May 6, 2024

Are the changes in core module the same as #3100 ?

@charliecheng630
Copy link
Contributor Author

Are the changes in core module the same as #3100 ?

Yes.

@charliecheng630
Copy link
Contributor Author

Update. Please help to review again when you have time~

Copy link
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

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

The JavaDoc for methods(dropXxx) like com.datastrato.gravitino.SupportsMetalakes#dropMetalake should be reviewed and revised if needed.

@charliecheng630
Copy link
Contributor Author

Updated. Please help to review again when you have time, thanks!

@charliecheng630
Copy link
Contributor Author

charliecheng630 commented May 9, 2024

@mchades Updated. Please help to review again when you have time, thanks!

@@ -76,6 +81,10 @@ static int getErrorCodeFromMessage(String message) {
return CODE_DATABASE_EXISTS;
}

if (DATABASE_NOT_EXISTS_PATTERN.matcher(message).matches()) {
return CODE_DATABASE_NOT_EXISTS;
Copy link
Contributor

@mchades mchades May 10, 2024

Choose a reason for hiding this comment

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

Could you please help to review those Doris changes? @yuqi1129 @zhoukangcn

Copy link
Contributor

Choose a reason for hiding this comment

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

since #3100 merged, this change is no longer needed, right?

@jerryshao
Copy link
Collaborator

@charliecheng630 would you please rebase the code?

@@ -75,7 +75,7 @@ Metalake alterMetalake(NameIdentifier ident, MetalakeChange... changes)
* Drop a metalake with specified identifier.
*
* @param ident The identifier of the metalake.
* @return True if the metalake was dropped, false otherwise.
* @return True if the metalake was dropped, false if the metalake does not exist.
*/
boolean dropMetalake(NameIdentifier ident);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you don't change the metalake and catalog related implementations, can you confirm do they have the correct implementation?

Assertions.assertEquals(Response.Status.OK.getStatusCode(), resp2.getStatus());
DropResponse dropResponse2 = resp2.readEntity(DropResponse.class);
Assertions.assertEquals(0, dropResponse2.getCode());
Assertions.assertFalse(dropResponse2.dropped());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you'd better also add a metalake integration test.

@jerryshao
Copy link
Collaborator

@charliecheng630 can you please also confirm that if anything should be changed in the client side?

@@ -1264,7 +1264,8 @@ void testNameSpec() {
Assertions.assertTrue(
Arrays.stream(schemaIdents).anyMatch(s -> s.name().equals(testSchemaName)));

Assertions.assertTrue(catalog.asSchemas().dropSchema(schemaIdent, false));
Assertions.assertTrue(
catalog.asSchemas().dropSchema(schemaIdent, false), "schema should be dropped");
Copy link
Contributor

Choose a reason for hiding this comment

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

I notice that schema should be dropped use many times. Do we need to define a function in ITUtils?

Copy link
Contributor

Choose a reason for hiding this comment

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

Are those changes still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are those changes still needed?

yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not? #3100 did the same things in high level

@charliecheng630
Copy link
Contributor Author

@mchades Rebased & updated. Please help to review again when you have time, thanks!

@@ -239,13 +239,12 @@ public JdbcSchema alterSchema(NameIdentifier ident, SchemaChange... changes)
*
* @param ident The identifier of the schema to drop.
* @param cascade If set to true, drops all the tables in the schema as well.
* @return true if the schema was dropped successfully, false otherwise.
* @return true if the schema is successfully dropped; false if the table does not exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

table -> schema

Comment on lines 68 to +71
case CODE_DATABASE_NOT_EXISTS:
return new NoSuchSchemaException(se, se.getMessage());
case CODE_UNKNOWN_DATABASE:
return new NoSuchSchemaException(se, se.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be simplified to:

case CODE_DATABASE_NOT_EXISTS:
case CODE_UNKNOWN_DATABASE:
  return new NoSuchSchemaException(se, se.getMessage());

@@ -122,7 +123,10 @@ private void clearTableAndSchema() {
NameIdentifier[] nameIdentifiers =
catalog.asTableCatalog().listTables(Namespace.of(metalakeName, catalogName, schemaName));
for (NameIdentifier nameIdentifier : nameIdentifiers) {
catalog.asTableCatalog().dropTable(nameIdentifier);
// Currently, tables with a status of SCHEMA_CHANGE are not supported for drop operations.
if (!nameIdentifier.name().contains("index")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

where does the index table come from? I don't see the table creation in test

// Currently, tables with a status of SCHEMA_CHANGE are not supported for drop operations.
if (!nameIdentifier.name().contains("index")) {
catalog.asTableCatalog().dropTable(nameIdentifier);
}
}
catalog.asSchemas().dropSchema(NameIdentifier.of(metalakeName, catalogName, schemaName), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

since here set cascade=true, the drop table operations above seems unnecessary

Copy link
Contributor

Choose a reason for hiding this comment

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

this file change is unnecessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] revisit all the dropXXX interfaces to have a consistent behavior
4 participants