Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-24218

Drop table used by a materialized view

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Duplicate
    • 3.1.0
    • None
    • CLI, Hive, HiveServer2, Metastore
    • None

    Description

      I have discovered that it's possible to drop a table used by a materialized view. When I drop this table, the result is OK while I think this action should be refused. When I check in the metastore database, I can see that the table has been partially deleted (ie : the reference of the table still exists inĀ TBLS and in MV_TABLES_USED). This introduces an inconsistency in the metastore.

      Steps to reproduced :

      
      jdbc:hive2://localhost.> use use ptest2_db_dev;
      No rows affected (0.067 seconds)
      0: jdbc:hive2://localhost.> create table table_blocked (id string);
      No rows affected (0.97 seconds)
      0: jdbc:hive2://localhost.> desc table_blocked;
      +-----------+------------+----------+
      | col_name  | data_type  | comment  |
      +-----------+------------+----------+
      | id        | string     |          |
      +-----------+------------+----------+
      1 row selected (0.171 seconds)
      0: jdbc:hive2://localhost.> create materialized view table_blocked_mv as select * from table_blocked;
      No rows affected (18.055 seconds)
      0: jdbc:hive2://localhost.> desc table_blocked_mv;
      +-----------+------------+----------+
      | col_name  | data_type  | comment  |
      +-----------+------------+----------+
      | id        | string     |          |
      +-----------+------------+----------+
      1 row selected (0.316 seconds)
      0: jdbc:hive2://localhost.> drop table table_blocked;
      No rows affected (10.803 seconds)
      0: jdbc:hive2://localhost.> desc table_blocked_mv;
      +-----------+------------+----------+
      | col_name  | data_type  | comment  |
      +-----------+------------+----------+
      | id        | string     |          |
      +-----------+------------+----------+
      1 row selected (0.222 seconds)
      0: jdbc:hive2://localhost.> desc table_blocked;
      Error: Error while compiling statement: FAILED: SemanticException Unable to fetch table table_blocked. null (state=42000,code=40000)
      0: jdbc:hive2://localhost.> select * from table_blocked_mv;
      Error: Error while compiling statement: FAILED: SemanticException Table ptest2_db_dev.table_blocked not found when trying to obtain it to check masking/filtering policies (state=42000,code=40000)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              stephbat stephbat
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: