You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Fan Yunbo (JIRA)" <ji...@apache.org> on 2016/09/01 09:34:20 UTC

[jira] [Created] (HIVE-14686) Get unexpected command type when execute query "CREATE TABLE IF NOT EXISTS ... AS"

Fan Yunbo created HIVE-14686:
--------------------------------

             Summary: Get unexpected command type when execute query "CREATE TABLE IF NOT EXISTS ... AS"
                 Key: HIVE-14686
                 URL: https://issues.apache.org/jira/browse/HIVE-14686
             Project: Hive
          Issue Type: Bug
    Affects Versions: 1.1.0
            Reporter: Fan Yunbo
            Assignee: Fan Yunbo


See the query: create table if not exists DST as select * from SRC;
if the table DST doesn't exist, SessionState.get().getHiveOperation() will return HiveOperation.CREATETABLE_AS_SELECT;
But if the table DST already exists, it will return HiveOperation.CREATETABLE;

It really makes some trouble for those who judge operation type by SessionState.get().getHiveOperation().

The reason I find out is that the function analyzeCreateTable in SemanticAnalyzer.java will return null and won't set the correct command type if the table already exists.

Here is the related code:
// check for existence of table
    if (ifNotExists) {
      try {
        Table table = getTable(qualifiedTabName, false);
        if (table != null) { // table exists
          return null;
        }
      } catch (HiveException e) {
        // should not occur since second parameter to getTableWithQN is false
        throw new IllegalStateException("Unxpected Exception thrown: " + e.getMessage(), e);
      }
    }




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)