Repository: tajo Updated Branches: refs/heads/branch-0.11.0 957319861 -> e1bd549dd
TAJO-1933: When a simple query executed on partitioned tables, the number of result rows is always the number of rows of the whole table. Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/e1bd549d Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/e1bd549d Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/e1bd549d Branch: refs/heads/branch-0.11.0 Commit: e1bd549dd79aa779e417c58b44421aa0b39bb1e9 Parents: 9573198 Author: Jihoon Son <[email protected]> Authored: Sat Oct 17 11:54:35 2015 +0900 Committer: Jihoon Son <[email protected]> Committed: Sat Oct 17 11:54:35 2015 +0900 ---------------------------------------------------------------------- CHANGES | 3 +++ .../java/org/apache/tajo/cli/tsql/TajoCli.java | 2 +- .../java/org/apache/tajo/cli/tsql/TestTajoCli.java | 17 +++++++++++++++++ .../TestTajoCli/testNonForwardQueryPause.result | 2 +- ...ultRowNumWhenSelectingOnPartitionedTable.result | 4 ++++ .../org/apache/tajo/master/exec/QueryExecutor.java | 12 ------------ 6 files changed, 26 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/e1bd549d/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 23ebd03..b8d9ecf 100644 --- a/CHANGES +++ b/CHANGES @@ -285,6 +285,9 @@ Release 0.11.0 - unreleased BUG FIXES + TAJO-1933: When a simple query executed on partitioned tables, the number of + result rows is always the number of rows of the whole table. (jihoon) + TAJO-1928: Can't read parquet on hive meta. (jinho) TAJO-1926: Disable partition pruning using catalog temporarily. (jaehwa) http://git-wip-us.apache.org/repos/asf/tajo/blob/e1bd549d/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java ---------------------------------------------------------------------- diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java index 8ae7075..f9379f9 100644 --- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java +++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java @@ -50,7 +50,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; -public class TajoCli { +public class TajoCli implements Closeable { public static final int SHUTDOWN_HOOK_PRIORITY = 50; public static final String ERROR_PREFIX = "ERROR: "; public static final String KILL_PREFIX = "KILL: "; http://git-wip-us.apache.org/repos/asf/tajo/blob/e1bd549d/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java index 0503d5d..ad2d50b 100644 --- a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java +++ b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java @@ -18,6 +18,7 @@ package org.apache.tajo.cli.tsql; +import com.google.common.io.NullOutputStream; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.PosixParser; @@ -473,6 +474,22 @@ public class TestTajoCli { } } + @Test + public void testResultRowNumWhenSelectingOnPartitionedTable() throws Exception { + try (TajoCli cli2 = new TajoCli(cluster.getConfiguration(), new String[]{}, null, System.in, + new NullOutputStream())) { + cli2.executeScript("create table region_part (r_regionkey int8, r_name text) " + + "partition by column (r_comment text) as select * from region"); + + setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName()); + tajoCli.executeScript("select r_comment from region_part where r_comment = 'hs use ironic, even requests. s'"); + String consoleResult = new String(out.toByteArray()); + assertOutputResult(consoleResult); + } finally { + tajoCli.executeScript("drop table region_part purge"); + } + } + // TODO: This should be removed at TAJO-1891 @Test public void testAddPartitionNotimplementedException() throws Exception { http://git-wip-us.apache.org/repos/asf/tajo/blob/e1bd549d/tajo-core-tests/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result b/tajo-core-tests/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result index 90074e2..ce6d9c3 100644 --- a/tajo-core-tests/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result +++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testNonForwardQueryPause.result @@ -3,4 +3,4 @@ l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice 1, 1, 7706, 1, 17.0, 21168.23, 0.04, 0.02, N, O, 1996-03-13, 1996-02-12, 1996-03-22, DELIVER IN PERSON, TRUCK, egular courts above the 1, 1, 7311, 2, 36.0, 45983.16, 0.09, 0.06, N, O, 1996-04-12, 1996-02-28, 1996-04-20, TAKE BACK RETURN, MAIL, ly final dependencies: slyly bold (2 rows, continue... 'q' is quit) -(unknown row number, , 0 B selected) \ No newline at end of file +(unknown row number, , unknown bytes selected) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e1bd549d/tajo-core-tests/src/test/resources/results/TestTajoCli/testResultRowNumWhenSelectingOnPartitionedTable.result ---------------------------------------------------------------------- diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testResultRowNumWhenSelectingOnPartitionedTable.result b/tajo-core-tests/src/test/resources/results/TestTajoCli/testResultRowNumWhenSelectingOnPartitionedTable.result new file mode 100644 index 0000000..8a7419a --- /dev/null +++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testResultRowNumWhenSelectingOnPartitionedTable.result @@ -0,0 +1,4 @@ +r_comment +------------------------------- +hs use ironic, even requests. s +(1 rows, , 0 B selected) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e1bd549d/tajo-core/src/main/java/org/apache/tajo/master/exec/QueryExecutor.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/QueryExecutor.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/QueryExecutor.java index 2716800..a8f3324 100644 --- a/tajo-core/src/main/java/org/apache/tajo/master/exec/QueryExecutor.java +++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/QueryExecutor.java @@ -291,7 +291,6 @@ public class QueryExecutor { final TableDesc resultDesc = new TableDesc("", scanNode.getOutSchema(), new TableMeta(BuiltinStorages.DRAW, table.getMeta().getOptions()), null); - resultDesc.setStats(new TableStats()); // push down limit int maxRow = Integer.MAX_VALUE; @@ -301,17 +300,6 @@ public class QueryExecutor { scanNode.setLimit(maxRow); } - // get the estimated number of rows - long estimatedRowNum; - if (table.getStats().getNumRows() == 0) { - estimatedRowNum = TajoConstants.UNKNOWN_ROW_NUMBER; - } else { - estimatedRowNum = table.getStats().getNumRows(); - } - estimatedRowNum = Math.min(estimatedRowNum, maxRow); - resultDesc.getStats().setNumRows(estimatedRowNum); - - final QueryInfo queryInfo = context.getQueryJobManager().createNewSimpleQuery(queryContext, session, query, (LogicalRootNode) plan.getRootBlock().getRoot());
