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 34DF6200B4A for ; Wed, 20 Jul 2016 20:55:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 336B8160A5B; Wed, 20 Jul 2016 18:55:22 +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 7E7AA160A64 for ; Wed, 20 Jul 2016 20:55:21 +0200 (CEST) Received: (qmail 43648 invoked by uid 500); 20 Jul 2016 18:55:20 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 43537 invoked by uid 99); 20 Jul 2016 18:55:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2016 18:55:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 7F9692C0D56 for ; Wed, 20 Jul 2016 18:55:20 +0000 (UTC) Date: Wed, 20 Jul 2016 18:55:20 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-4673) Implement "DROP TABLE IF EXISTS" for drill to prevent FAILED status on command return MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 20 Jul 2016 18:55:22 -0000 [ https://issues.apache.org/jira/browse/DRILL-4673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15386437#comment-15386437 ] ASF GitHub Bot commented on DRILL-4673: --------------------------------------- Github user vdiravka commented on a diff in the pull request: https://github.com/apache/drill/pull/541#discussion_r71585214 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java --- @@ -106,36 +106,43 @@ public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConv } } - /** Handler for Drop View DDL command. */ - public static class DropView extends ViewHandler { - public DropView(SqlHandlerConfig config) { + /** Handler for Drop View [If Exists] DDL command. */ + public static class DropViewIfExists extends ViewHandler { + public DropViewIfExists(SqlHandlerConfig config) { super(config); } @Override public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException { - SqlDropView dropView = unwrap(sqlNode, SqlDropView.class); - final String viewToDrop = dropView.getName(); + SqlDropViewIfExists dropView = unwrap(sqlNode, SqlDropViewIfExists.class); + final String viewName = dropView.getName(); final AbstractSchema drillSchema = SchemaUtilites.resolveToMutableDrillSchema(context.getNewDefaultSchema(), dropView.getSchemaPath()); final String schemaPath = drillSchema.getFullSchemaName(); - final Table existingTable = SqlHandlerUtil.getTableFromSchema(drillSchema, viewToDrop); - if (existingTable != null && existingTable.getJdbcTableType() != Schema.TableType.VIEW) { - throw UserException.validationError() - .message("[%s] is not a VIEW in schema [%s]", viewToDrop, schemaPath) - .build(logger); - } else if (existingTable == null) { - throw UserException.validationError() - .message("Unknown view [%s] in schema [%s].", viewToDrop, schemaPath) - .build(logger); + final Table viewToDrop = SqlHandlerUtil.getTableFromSchema(drillSchema, viewName); + if (dropView.checkViewExistence()) { + if (viewToDrop == null || viewToDrop.getJdbcTableType() != Schema.TableType.VIEW){ --- End diff -- Answered above. > Implement "DROP TABLE IF EXISTS" for drill to prevent FAILED status on command return > ------------------------------------------------------------------------------------- > > Key: DRILL-4673 > URL: https://issues.apache.org/jira/browse/DRILL-4673 > Project: Apache Drill > Issue Type: New Feature > Components: Functions - Drill > Reporter: Vitalii Diravka > Assignee: Vitalii Diravka > Priority: Minor > Labels: drill > > Implement "DROP TABLE IF EXISTS" for drill to prevent FAILED status on command "DROP TABLE" return if table doesn't exist. > The same for "DROP VIEW IF EXISTS" -- This message was sent by Atlassian JIRA (v6.3.4#6332)