Repository: drill
Updated Branches:
  refs/heads/master e22b8ff27 -> cd0110721


DRILL-4083: ScanPrel's CPU cost should not be zero even if column count is zero

close apache/drill#253


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/cd011072
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/cd011072
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/cd011072

Branch: refs/heads/master
Commit: cd01107217c751e59be7525b725035f5deecd75a
Parents: e22b8ff
Author: Hsuan-Yi Chu <[email protected]>
Authored: Thu Nov 12 15:01:10 2015 -0800
Committer: Jinfeng Ni <[email protected]>
Committed: Fri Nov 13 17:30:09 2015 -0800

----------------------------------------------------------------------
 .../org/apache/drill/exec/hive/TestHiveStorage.java  | 15 +++++++++++++++
 .../apache/drill/exec/planner/physical/ScanPrel.java |  5 +++--
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/cd011072/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
----------------------------------------------------------------------
diff --git 
a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
 
b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
index 1112e8c..9d784fe 100644
--- 
a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
+++ 
b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
@@ -36,6 +36,21 @@ public class TestHiveStorage extends HiveTestBase {
     test(String.format("alter session set `%s` = true", 
PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY));
   }
 
+
+  @Test // DRILL-4083
+  public void testNativeScanWhenNoColumnIsRead() throws Exception {
+    try {
+      test(String.format("alter session set `%s` = true", 
ExecConstants.HIVE_OPTIMIZE_SCAN_WITH_NATIVE_READERS));
+
+      String query = "SELECT count(*) FROM hive.readtest_parquet";
+      testPhysicalPlan(query, "hive-drill-native-parquet-scan");
+    } finally {
+      test(String.format("alter session set `%s` = %s",
+          ExecConstants.HIVE_OPTIMIZE_SCAN_WITH_NATIVE_READERS,
+              
ExecConstants.HIVE_OPTIMIZE_SCAN_WITH_NATIVE_READERS_VALIDATOR.getDefault().bool_val
 ? "true" : "false"));
+    }
+  }
+
   @Test
   public void hiveReadWithDb() throws Exception {
     test("select * from hive.kv");

http://git-wip-us.apache.org/repos/asf/drill/blob/cd011072/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ScanPrel.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ScanPrel.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ScanPrel.java
index f69ee4c..b100d90 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ScanPrel.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ScanPrel.java
@@ -118,8 +118,9 @@ public class ScanPrel extends AbstractRelNode implements 
DrillScanPrel {
     // double rowCount = RelMetadataQuery.getRowCount(this);
     double rowCount = stats.getRecordCount();
 
-
-    double cpuCost = rowCount * columnCount; // for now, assume cpu cost is 
proportional to row count.
+    // As DRILL-4083 points out, when columnCount == 0, cpuCost becomes zero,
+    // which makes the costs of HiveScan and HiveDrillNativeParquetScan the 
same
+    double cpuCost = rowCount * Math.max(columnCount, 1); // For now, assume 
cpu cost is proportional to row count.
 
     // If a positive value for CPU cost is given multiply the default CPU cost 
by given CPU cost.
     if (stats.getCpuCost() > 0) {

Reply via email to