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

commit 5862a39468773bba8aed51cc740b0ed9a8909fb4
Author: Venkata Jyothsna Donapati <[email protected]>
AuthorDate: Mon Apr 29 12:27:44 2019 -0700

    DRILL-7225: Fixed merging ColumnTypeInfo for files with different schemas
    closes #1773
---
 .../drill/exec/store/parquet/metadata/Metadata.java     |  4 ++++
 .../exec/store/parquet/TestParquetMetadataCache.java    | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata.java
index 5459a8a..b239be7 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata.java
@@ -321,6 +321,10 @@ public class Metadata {
         Map<ColumnTypeMetadata_v4.Key, Long> totalNullCountMap = 
parquetFileAndRowCountMetadata.getTotalNullCountMap();
         for (ColumnTypeMetadata_v4.Key column: totalNullCountMap.keySet()) {
           ColumnTypeMetadata_v4 columnTypeMetadata_v4 = 
columnTypeInfoSet.get(column);
+          // If the column is not present in columnTypeInfoSet, get it from 
parquetTableMetadata
+          if (columnTypeMetadata_v4 == null) {
+            columnTypeMetadata_v4 = 
parquetTableMetadata.getColumnTypeInfoMap().get(column);
+          }
           // If the existing total null count or the null count of the child 
file is unknown(-1), update the total null count
           // as unknown
           if ( columnTypeMetadata_v4.totalNullCount < 0 || 
totalNullCountMap.get(column) < 0) {
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetMetadataCache.java
 
b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetMetadataCache.java
index 8280061..5799299 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetMetadataCache.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetMetadataCache.java
@@ -1385,4 +1385,21 @@ public class TestParquetMetadataCache extends 
PlanTestBase {
         .go();
   }
 
+  @Test
+  public void testRefreshSchemaChange() throws Exception {
+    String tableName = "orders_nation_ctas";
+    test("use dfs");
+
+    test("create table `%s/t1` as select * from cp.`tpch/orders.parquet`", 
tableName);
+    test("create table `%s/t2` as select * from cp.`tpch/nation.parquet`", 
tableName);
+    String query = String.format("refresh table metadata %s", tableName);
+
+    testBuilder()
+            .sqlQuery(query)
+            .unOrdered()
+            .baselineColumns("ok", "summary")
+            .baselineValues(true, "Successfully updated metadata for table 
orders_nation_ctas.")
+            .go();
+    checkForMetadataFile(tableName);
+  }
 }

Reply via email to