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.
diff --git a/CHANGES b/CHANGES
index 23ebd03..b8d9ecf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -285,6 +285,9 @@
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)
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.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: ";
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 @@
}
}
+ @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 {
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 @@
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
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
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 @@
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 @@
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());