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

Create or Replace a View fails with "Unable to alter table. The following columns have types incompatible with the existing columns in their respective positions"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.1.0
    • None
    • Database/Schema
    • None
    • Hive 2.1

    Description

      Create or Replace a view with different column types may fail with error :

      FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Unable to alter table. The following columns have types incompatible with the existing columns in their respective positions :
      i
      

      Here is minimum reproduce:

      CREATE TABLE testtype(i int, s1 string);
      
      DDL1:
      create or replace view v1 (s1) 
      as Select s1 from testtype;
      
      DDL2:
      create or replace view v1 (i,s1) 
      as Select i, s1 from testtype ;
      
      FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Unable to alter table. The following columns have types incompatible with the existing columns in their respective positions :
      i
      

      Only Workaround is:
      To drop the view and Create view again.

      We should allow "Create or Replace View" to work even if the column types are different.
      It should work like "Drop View" and then "Create a View".

      Attachments

        Activity

          People

            Unassigned Unassigned
            haozhu Hao Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: