Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-834

CREATE TABLE LIKE fails if source is a view

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Impala 1.2.3
    • Impala 1.4
    • None
    • None

    Description

      Sometimes it's convenient to refine a schema design by iteration through multiple variations on a view, then in the end create a table with the same column definitions as that view. Or make a view + an identical table to serve as a materialized view. However, CREATE TABLE <table_name> LIKE <view_name> throws an error in Impala:

      (Shell build version: Impala Shell v1.2.3 (1cab04c) built on Fri Dec 20 19:39:39 PST 2013)
      [localhost:21000] > use view_on_regexp;
      [localhost:21000] > create table t1 (x int);
      [localhost:21000] > create view v1 as select * from t1;
      [localhost:21000] > create table t2 like v1;
      ERROR: TableLoadingException: Failed to load metadata for table: t2
      CAUSED BY: NullPointerException: null

      After this point, the metastore seems to be in an inconsistent state. You can't create a table with the same name as the failed CREATE TABLE LIKE statement, because it's stated to already exist, but you also can't drop it because it's not found:

      [localhost:21000] > create table t2 like v1;
      ERROR: InternalException: Table t2 already exists
      [localhost:21000] > drop table t2;
      ERROR: AnalysisException: Table does not exist: view_on_regexp.t2

      That's what happens with the original 1.2.3 bits. I thought the problem might be fixed with more recent 1.2.3 bits, but it seems to have mutated instead. CREATE TABLE LIKE doesn't throw an error but there's still something wrong with the metadata afterward so you can't access the table created via CREATE TABLE LIKE:

      (Shell build version: Impala Shell v1.3.0-INTERNAL (b0ad015) built on Sun Feb 16 22:03:26 PST 2014)
      [localhost:21000] > create table t1 (x int);
      [localhost:21000] > create view v1 as select * from t1;
      [localhost:21000] > create table t2 like v1;
      [localhost:21000] > select * from t2;
      ERROR: AnalysisException: Failed to load metadata for table: create_table_like_view.t2
      CAUSED BY: TableLoadingException: Failed to load metadata for table: t2
      CAUSED BY: NullPointerException: null

      After Impala starts giving the error 'Failed to load metadata for table: t2', doing 'INVALIDATE METADATA t2' does not appear to help, the error persists.

      Attachments

        Activity

          People

            anusha_impala_6c97 Anusha Dasarakothapalli
            jrussell John Russell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: