Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 88D28200B8A for ; Fri, 9 Sep 2016 09:19:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 85B3B160AB6; Fri, 9 Sep 2016 07:19:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D9001160AC2 for ; Fri, 9 Sep 2016 09:19:22 +0200 (CEST) Received: (qmail 50856 invoked by uid 500); 9 Sep 2016 07:19:22 -0000 Mailing-List: contact issues-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list issues@hive.apache.org Received: (qmail 50817 invoked by uid 99); 9 Sep 2016 07:19:22 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Sep 2016 07:19:22 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D69932C1B79 for ; Fri, 9 Sep 2016 07:19:21 +0000 (UTC) Date: Fri, 9 Sep 2016 07:19:21 +0000 (UTC) From: "Fan Yunbo (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HIVE-14686) Get unexpected command type when execute query "CREATE TABLE IF NOT EXISTS ... AS" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 09 Sep 2016 07:19:23 -0000 [ https://issues.apache.org/jira/browse/HIVE-14686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fan Yunbo updated HIVE-14686: ----------------------------- Status: Patch Available (was: Open) > 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 > Fix For: 2.2.0 > > Attachments: HIVE-14686.1.patch, HIVE-14686.2.patch, HIVE-14686.3.patch, HIVE-14686.4.patch > > > See the query: > {code} > create table if not exists DST as select * from SRC; > {code} > 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: > {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); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)