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 7E790200B66 for ; Thu, 18 Aug 2016 16:35:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7CFB1160A86; Thu, 18 Aug 2016 14:35:09 +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 9CBD0160AAE for ; Thu, 18 Aug 2016 16:35:08 +0200 (CEST) Received: (qmail 48883 invoked by uid 500); 18 Aug 2016 14:35:07 -0000 Mailing-List: contact dev-help@impala.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@impala.incubator.apache.org Delivered-To: mailing list dev@impala.incubator.apache.org Received: (qmail 48872 invoked by uid 99); 18 Aug 2016 14:35:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2016 14:35:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 2B7CA1A137E for ; Thu, 18 Aug 2016 14:35:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.162 X-Spam-Level: * X-Spam-Status: No, score=1.162 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RDNS_DYNAMIC=0.363, SPF_PASS=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id xKrlwOM_Hepu for ; Thu, 18 Aug 2016 14:35:02 +0000 (UTC) Received: from ip-10-146-233-104.ec2.internal (ec2-75-101-130-251.compute-1.amazonaws.com [75.101.130.251]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 0AA825FAF4 for ; Thu, 18 Aug 2016 14:35:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ip-10-146-233-104.ec2.internal (8.14.4/8.14.4) with ESMTP id u7IEZ002021160; Thu, 18 Aug 2016 14:35:00 GMT Message-Id: <201608181435.u7IEZ002021160@ip-10-146-233-104.ec2.internal> Date: Thu, 18 Aug 2016 14:35:00 +0000 From: "Amos Bird (Code Review)" To: impala-cr@cloudera.com, dev@impala.incubator.apache.org CC: Alex Behm Reply-To: amosbird@gmail.com X-Gerrit-MessageType: newpatchset Subject: =?UTF-8?Q?=5BImpala-ASF-CR=5D_IMPALA-1654=3A_Partition_expr_in_DDL_operations=2E=0A?= X-Gerrit-Change-Id: I2c9162fcf9d227b8daf4c2e761d57bab4e26408f X-Gerrit-ChangeURL: X-Gerrit-Commit: e87ed3dd3bb482bc0b5c8aee7a302122eeeddb43 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.2 archived-at: Thu, 18 Aug 2016 14:35:09 -0000 Amos Bird has uploaded a new patch set (#2). Change subject: IMPALA-1654: Partition expr in DDL operations. ...................................................................... IMPALA-1654: Partition expr in DDL operations. This commit handles partition related DDL in a more general way. We can now use compound predicates to specify a list of partitions in statement like ALTER TABLE DROP PARTITION and COMPUTE INCREMENTAL STATS, etc. It will also make sure some statements only accept one partition at a time, such as PARTITION SET LOCATION and LOAD DATA. ALTER TABLE ADD PARTITION remains using the old PartitionKeyValue's logic. The changed partition related DDLs are as follows, Table: p (i int) partitioned by (j int, k string) Partitions: +-------+---+-------+--------+------+--------------+-------------------+ | j | k | #Rows | #Files | Size | Bytes Cached | Cache Replication | +-------+---+-------+--------+------+--------------+-------------------+ | 1 | a | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | 1 | b | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | 1 | c | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | 2 | d | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | 2 | e | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | 2 | f | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | Total | | -1 | 0 | 0B | 0B | | +-------+---+-------+--------+------+--------------+-------------------+ 1. show files in p partition (j<2, k='a'); 2. alter table p partition (j<2, k in ("b","c") set cached in 'testPool'; // j can appear more than once, 3.1. alter table p partition (j<2, j>0, k<>"d") set uncached; // it is the same as 3.2. alter table p partition (j<2 and j>0, not k="e") set uncached; // we can also do 'or' 3.3. alter table p partition (j<2 or j>0, k like "%") set uncached; // missing 'k' matches all values of k 4. alter table p partition (j<2) set fileformat textfile; 5. alter table p partition (k rlike ".*") set serdeproperties ("k"="v"); 6. alter table p partition (j is not null) set tblproperties ("k"="v"); 7. alter table p drop partition (j<2); 8. compute incremental stats p partition(j<2); The remaining old partition related DDLs are as follows, 1. load data inpath '/path/from' into table p partition (j=2, k="d"); 2. alter table p add partition (j=2, k="g"); 3. alter table p partition (j=2, k="g") set location '/path/to'; 4. insert into p partition (j=2, k="g") values (1), (2), (3); The only senario that allows partition predicates to return empty partition set is "ALTER TABLE DROP IF EXISTS PARTITION". Examples: [localhost.localdomain:21000] > alter table p drop partition (j=2, k="f"); Query: alter table p drop partition (j=2, k="f") +-------------------------+ | summary | +-------------------------+ | Dropped 1 partition(s). | +-------------------------+ Fetched 1 row(s) in 0.78s [localhost.localdomain:21000] > alter table p drop partition (j=2, k<"f"); Query: alter table p drop partition (j=2, k<"f") +-------------------------+ | summary | +-------------------------+ | Dropped 2 partition(s). | +-------------------------+ Fetched 1 row(s) in 0.41s [localhost.localdomain:21000] > alter table p drop partition (k="a"); Query: alter table p drop partition (k="a") +-------------------------+ | summary | +-------------------------+ | Dropped 1 partition(s). | +-------------------------+ Fetched 1 row(s) in 0.25s [localhost.localdomain:21000] > show partitions p; Query: show partitions p +-------+---+-------+--------+------+--------------+-------------------+ | j | k | #Rows | #Files | Size | Bytes Cached | Cache Replication | +-------+---+-------+--------+------+--------------+-------------------+ | 1 | b | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | 1 | c | -1 | 0 | 0B | NOT CACHED | NOT CACHED | | Total | | -1 | 0 | 0B | 0B | | +-------+---+-------+--------+------+--------------+-------------------+ Fetched 3 row(s) in 0.01s Change-Id: I2c9162fcf9d227b8daf4c2e761d57bab4e26408f --- M be/src/service/query-exec-state.cc M be/src/service/query-exec-state.h M common/thrift/CatalogService.thrift M common/thrift/Frontend.thrift M common/thrift/JniCatalog.thrift M fe/src/main/cup/sql-parser.cup M fe/src/main/java/com/cloudera/impala/analysis/AlterTableDropPartitionStmt.java M fe/src/main/java/com/cloudera/impala/analysis/AlterTableSetCachedStmt.java M fe/src/main/java/com/cloudera/impala/analysis/AlterTableSetFileFormatStmt.java M fe/src/main/java/com/cloudera/impala/analysis/AlterTableSetLocationStmt.java M fe/src/main/java/com/cloudera/impala/analysis/AlterTableSetStmt.java M fe/src/main/java/com/cloudera/impala/analysis/AlterTableSetTblProperties.java M fe/src/main/java/com/cloudera/impala/analysis/AlterTableStmt.java M fe/src/main/java/com/cloudera/impala/analysis/ComputeStatsStmt.java M fe/src/main/java/com/cloudera/impala/analysis/DropStatsStmt.java A fe/src/main/java/com/cloudera/impala/analysis/PartitionSet.java M fe/src/main/java/com/cloudera/impala/analysis/PartitionSpec.java A fe/src/main/java/com/cloudera/impala/analysis/PartitionSpecBase.java M fe/src/main/java/com/cloudera/impala/analysis/ShowFilesStmt.java M fe/src/main/java/com/cloudera/impala/catalog/CatalogServiceCatalog.java M fe/src/main/java/com/cloudera/impala/catalog/HdfsTable.java M fe/src/main/java/com/cloudera/impala/planner/HdfsPartitionPruner.java M fe/src/main/java/com/cloudera/impala/planner/SingleNodePlanner.java M fe/src/main/java/com/cloudera/impala/service/CatalogOpExecutor.java M fe/src/main/java/com/cloudera/impala/service/Frontend.java M fe/src/test/java/com/cloudera/impala/analysis/AnalyzeDDLTest.java M fe/src/test/java/com/cloudera/impala/analysis/ParserTest.java M shell/impala_client.py M testdata/workloads/functional-query/queries/QueryTest/alter-table.test A testdata/workloads/functional-query/queries/QueryTest/partition-ddl-predicates.test M tests/metadata/test_ddl.py 31 files changed, 1,160 insertions(+), 524 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/42/3942/2 -- To view, visit http://gerrit.cloudera.org:8080/3942 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I2c9162fcf9d227b8daf4c2e761d57bab4e26408f Gerrit-PatchSet: 2 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Amos Bird Gerrit-Reviewer: Alex Behm