[
https://issues.apache.org/jira/browse/TAJO-1926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14959092#comment-14959092
]
ASF GitHub Bot commented on TAJO-1926:
--------------------------------------
Github user blrunner commented on a diff in the pull request:
https://github.com/apache/tajo/pull/824#discussion_r42140463
--- Diff:
tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestPartitionedTableRewriter.java
---
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.planner;
+
+import org.apache.hadoop.fs.ContentSummary;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.tajo.LocalTajoTestingUtility;
+import org.apache.tajo.OverridableConf;
+import org.apache.tajo.QueryTestCaseBase;
+import org.apache.tajo.algebra.Expr;
+import org.apache.tajo.catalog.CatalogUtil;
+import org.apache.tajo.catalog.TableDesc;
+import org.apache.tajo.engine.query.QueryContext;
+import org.apache.tajo.plan.LogicalPlan;
+import org.apache.tajo.plan.logical.*;
+import org.apache.tajo.plan.rewrite.rules.PartitionedTableRewriter;
+import org.apache.tajo.util.CommonTestingUtil;
+import org.apache.tajo.util.FileUtil;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestPartitionedTableRewriter extends QueryTestCaseBase {
+
+ @Test
+ public final void testPartitionPruningUsingManuallyAddedPartition()
throws Exception {
+ String tableName =
"testPartitionPruningUsingManualAddedPartition".toLowerCase();
+ String canonicalTableName =
CatalogUtil.getCanonicalTableName("\"TestPartitionedTableRewriter\"",
tableName);
+
+ executeString("create table " + canonicalTableName + " (n_nationkey
INT8, n_name TEXT, n_regionkey INT8) " +
+ "partition by column(key TEXT)");
+
+ TableDesc tableDesc = catalog.getTableDesc(getCurrentDatabase(),
tableName);
+ assertNotNull(tableDesc);
+
+ FileSystem fs = FileSystem.get(conf);
+ Path path = new Path(tableDesc.getUri().toString() + "/key=part123");
+ fs.mkdirs(path);
+ FileUtil.writeTextToFile("1|ARGENTINA|1", new Path(path, "data"));
+
+ path = new Path(tableDesc.getUri().toString() + "/key=part456");
+ fs.mkdirs(path);
+ FileUtil.writeTextToFile("2|BRAZIL|1", new Path(path, "data"));
+
+ path = new Path(tableDesc.getUri().toString() + "/key=part789");
+ fs.mkdirs(path);
+ FileUtil.writeTextToFile("3|CANADA|1", new Path(path, "data"));
+
+ // Get all partitions
+ verifyFindFilteredPartitionPaths("SELECT * FROM " + canonicalTableName
+ " ORDER BY key", 3);
+
+ // Get partition with filter condition
+ verifyFindFilteredPartitionPaths("SELECT * FROM " + canonicalTableName
+ " WHERE key = 'part456' ORDER BY key", 4);
+
+ executeString("DROP TABLE " + canonicalTableName + " PURGE").close();
+ }
+
+ @Test
+ public final void testPartitionPruningUsingDirectories() throws
Exception {
+ String tableName =
"testPartitionPruningUsingDirectories".toLowerCase();
+ String canonicalTableName =
CatalogUtil.getCanonicalTableName("\"TestPartitionedTableRewriter\"",
tableName);
+
+ executeString(
+ "create table " + canonicalTableName + "(col1 int4, col2 int4)
partition by column(key float8) "
+ + " as select l_orderkey, l_partkey, l_quantity from
default.lineitem");
+
+ TableDesc tableDesc = catalog.getTableDesc(getCurrentDatabase(),
tableName);
+ assertNotNull(tableDesc);
+
+ // Get all partitions
+ verifyFindFilteredPartitionPaths("SELECT * FROM " + canonicalTableName
+ " ORDER BY key", 1);
+
+ // Get partition with filter condition
+ verifyFindFilteredPartitionPaths("SELECT * FROM " + canonicalTableName
+ " WHERE key = 17.0 ORDER BY key", 2);
+
+ executeString("DROP TABLE " + canonicalTableName + " PURGE").close();
+ }
+
+ private void verifyFindFilteredPartitionPaths(String sql, int type)
throws Exception {
--- End diff --
Reflected your comments.
> Disable partition pruning using catalog temporarily.
> ----------------------------------------------------
>
> Key: TAJO-1926
> URL: https://issues.apache.org/jira/browse/TAJO-1926
> Project: Tajo
> Issue Type: Sub-task
> Components: Catalog, Physical Operator, Planner/Optimizer
> Affects Versions: 0.11.0, 0.12.0
> Reporter: Jaehwa Jung
> Assignee: Jaehwa Jung
> Priority: Critical
> Fix For: 0.11.0
>
>
> We disabled alter table add partition temporarily at TAJO-1887. But when
> adding partitions with dfs command for external partitioned table, there is
> no way to add partition to catalog. As a result, users can't scan their
> partitions which are added manually to file system. So, we need to disable
> partition pruning using catalog until implement TAJO-1891.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)