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]Fix drop table in Hive and jdbc catalog when the file path does not exists. #4860

Closed
wants to merge 2 commits into from

Conversation

herefree
Copy link
Contributor

@herefree herefree commented Jan 8, 2025

Purpose

Fix drop table in Hive and jdbc catalog when the file path does not exists.

Linked issue: close #4853

Tests

API and Format

Documentation

@@ -598,6 +595,10 @@ public Optional<TableSchema> tableSchemaInFileSystem(Path tablePath, String bran
});
}

protected boolean tableExists(Identifier identifier) {
Copy link
Contributor

Choose a reason for hiding this comment

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

private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

private

In hive and jdbc catalog, tableExists method has different implement. So I used protected.

Identifier.create(databaseName, tableName), DEFAULT_TABLE_SCHEMA, false);
JdbcCatalog jdbcCatalog = (JdbcCatalog) catalog;
Path path = jdbcCatalog.getTableLocation(Identifier.create(databaseName, tableName));
// delete file path
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "delete table path" is better?

identifier.getDatabaseName(), identifier.getTableName()));
} catch (TException e) {
throw new RuntimeException(
"Cannot determine if table " + identifier.getFullName() + "exists.", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

"exists." -> " exists."

Identifier.create(databaseName, tableName),
addHiveTableParametersSchema,
false);
// delete file path
Copy link
Contributor

Choose a reason for hiding this comment

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

dito

catalog.dropTable(Identifier.create(databaseName, tableName), false);
List<String> tables = catalog.listTables(databaseName);
assertThat(tableName).isNotIn(tables);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This try statement is very big, maybe add "throw Exception" in the method signature is better?

@wwj6591812
Copy link
Contributor

What the relation between this pr and #4863?

@herefree
Copy link
Contributor Author

herefree commented Jan 8, 2025

What the relation between this pr and #4863?

It seems we resloved same problem. In UTCase and ITCase Spark 4.x and Spark 3.x, it still has some problem which I not sure how to solve.I'll close it.

@herefree herefree closed this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants