You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by so...@apache.org on 2019/04/11 21:12:31 UTC

[drill] branch master updated: DRILL-7166: Count query with wildcard should skip reading of metadata summary file

This is an automated email from the ASF dual-hosted git repository.

sorabh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e9befd  DRILL-7166: Count query with wildcard should skip reading of metadata summary file
1e9befd is described below

commit 1e9befd6477c918266cd8d7ef49c6a811e740eaa
Author: Venkata Jyothsna Donapati <jy...@gmail.com>
AuthorDate: Wed Apr 10 17:15:32 2019 -0700

    DRILL-7166: Count query with wildcard should skip reading of metadata summary file
---
 .../logical/ConvertCountToDirectScanRule.java      |  8 ++++-
 .../logical/TestConvertCountToDirectScan.java      | 36 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/ConvertCountToDirectScanRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/ConvertCountToDirectScanRule.java
index 63206c5..fd84e20 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/ConvertCountToDirectScanRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/ConvertCountToDirectScanRule.java
@@ -138,8 +138,14 @@ public class ConvertCountToDirectScanRule extends RelOptRule {
 
     //  Rule is applicable only if the statistics for row count and null count are available from the metadata,
     FormatSelection formatSelection = (FormatSelection) selection;
-    Pair<Boolean, Metadata_V4.MetadataSummary> status = checkMetadataForScanStats(settings, drillTable, formatSelection);
 
+    // Rule cannot be applied if the selection had wildcard since the totalrowcount cannot be read from the parent directory
+    if (formatSelection.getSelection().hadWildcard()) {
+      logger.debug("Rule does not apply when there is a wild card since the COUNT could not be determined from metadata.");
+      return;
+    }
+
+    Pair<Boolean, Metadata_V4.MetadataSummary> status = checkMetadataForScanStats(settings, drillTable, formatSelection);
     if (!status.getLeft()) {
       logger.debug("Rule does not apply since MetadataSummary metadata was not found.");
       return;
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/planner/logical/TestConvertCountToDirectScan.java b/exec/java-exec/src/test/java/org/apache/drill/exec/planner/logical/TestConvertCountToDirectScan.java
index d18ed45..4bd3a0f 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/planner/logical/TestConvertCountToDirectScan.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/planner/logical/TestConvertCountToDirectScan.java
@@ -238,4 +238,40 @@ public class TestConvertCountToDirectScan extends PlanTestBase {
       test("drop table if exists %s", tableName);
     }
   }
+
+  @Test
+  public void testCountsWithWildCard() throws Exception {
+    test("use dfs.tmp");
+    String tableName = "parquet_table_counts";
+
+    try {
+      for (int i = 0; i < 10; i++) {
+        test(String.format("create table `%s/12/%s` as select * from cp.`tpch/nation.parquet`", tableName, i));
+      }
+      test(String.format("create table `%s/2` as select * from cp.`tpch/nation.parquet`", tableName));
+      test(String.format("create table `%s/2/11` as select * from cp.`tpch/nation.parquet`", tableName));
+      test(String.format("create table `%s/2/12` as select * from cp.`tpch/nation.parquet`", tableName));
+
+      test("refresh table metadata %s", tableName);
+
+      String sql = String.format("select\n" +
+              "count(*) as star_count\n" +
+              "from `%s/1*`", tableName);
+
+      String usedMetaSummaryPattern = "usedMetadataSummaryFile = false";
+      String recordReaderPattern = "DynamicPojoRecordReader";
+
+      testPlanMatchingPatterns(sql, new String[]{usedMetaSummaryPattern, recordReaderPattern});
+
+      testBuilder()
+              .sqlQuery(sql)
+              .unOrdered()
+              .baselineColumns("star_count")
+              .baselineValues(250L)
+              .go();
+
+    } finally {
+      test("drop table if exists %s", tableName);
+    }
+  }
 }