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

[hive] Fix no longer possible to drop the hms table issue when table … #4863

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

XiaoHongbo-Hope
Copy link
Contributor

…not in fs (#4853)

Purpose Fix no longer possible to drop the hms table issue when table not in fs

Linked issue: close #4853

Tests

API and Format

Documentation

@LinMingQiang
Copy link
Contributor

Repeated : #4860

@@ -272,10 +272,14 @@ public void dropTable(Identifier identifier, boolean ignoreIfNotExists)
try {
getTable(identifier);
} catch (TableNotExistException e) {
if (!tableExistsInFileSystem(getTableLocation(identifier), DEFAULT_MAIN_BRANCH)) {
Copy link
Contributor

@Zouxxyy Zouxxyy Jan 8, 2025

Choose a reason for hiding this comment

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

As far as I know, before Spark calls catalog.dropTable, it actually invokes catalog.getTable fisrtly. It has already been skipped there.

case class DropTableExec(
    catalog: TableCatalog,
    ident: Identifier,
    ifExists: Boolean,
    purge: Boolean,
    invalidateCache: () => Unit) extends LeafV2CommandExec {

  override def run(): Seq[InternalRow] = {
    if (catalog.tableExists(ident)) {
      invalidateCache()
      if (purge) catalog.purgeTable(ident) else catalog.dropTable(ident)
    } else if (!ifExists) {
      throw QueryCompilationErrors.noSuchTableError(
        catalog.name() +: ident.namespace() :+ ident.name())
    }

    Seq.empty
  }

@XiaoHongbo-Hope XiaoHongbo-Hope marked this pull request as draft January 8, 2025 14:37
@XiaoHongbo-Hope XiaoHongbo-Hope marked this pull request as ready for review January 11, 2025 16:23
@Zouxxyy
Copy link
Contributor

Zouxxyy commented Jan 13, 2025

I'm OK with this modification. The core reason is that before dropping the table, the compute engine will call table exists -> catalog.getTable() to check if the table exists. Currently, our catalog.getTable() API only returns whether the table exists in the file system (even if it exists in HMS). Could @JingsongLi take another look at this?

identifier.getDatabaseName(),
identifier.getTableName());
try {
dropTableImpl(identifier);
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop table in getTable? This behavior is too strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks

@JingsongLi
Copy link
Contributor

I am -1 for this. You can enrich exception message. And user can just use drop table again?

@adrian-wang
Copy link
Contributor

Maybe just drop hms table in dropTable even if the table is not on FS?

@adrian-wang
Copy link
Contributor

Or, just recover and return a very basic dummy table when getTable, if we find the table is in hms and not on FileSystem?

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