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

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


The following commit(s) were added to refs/heads/master by this push:
     new f4be42c  HIVE-21831: Stats should be reset correctly during load of a 
partitioned ACID table (David Lavati via Laszlo Bodor)
f4be42c is described below

commit f4be42c5726a01479991ba6b6b6dc93f776648d5
Author: David Lavati <[email protected]>
AuthorDate: Wed Jun 12 09:30:45 2019 +0200

    HIVE-21831: Stats should be reset correctly during load of a partitioned 
ACID table (David Lavati via Laszlo Bodor)
    
    Signed-off-by: Laszlo Bodor <[email protected]>
---
 .../org/apache/hadoop/hive/ql/metadata/Hive.java    |  2 +-
 .../test/org/apache/hadoop/hive/ql/TestTxnExIm.java | 21 +++++++++++++++++++++
 .../test/results/clientpositive/llap/mm_exim.q.out  |  1 -
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java 
b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index fad96f4..2ae1db5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -2189,7 +2189,7 @@ public class Hive {
 
       // column stats will be inaccurate
       if (resetStatistics) {
-        StatsSetupConst.clearColumnStatsState(newTPart.getParameters());
+        StatsSetupConst.setBasicStatsState(newTPart.getParameters(), 
StatsSetupConst.FALSE);
       }
 
       // recreate the partition if it existed before
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnExIm.java 
b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnExIm.java
index 624bc01..fe9f900 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnExIm.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnExIm.java
@@ -391,6 +391,27 @@ 
target/tmp/org.apache.hadoop.hive.ql.TestTxnCommands-1521148657811/
     checkResult(expected, testQuery, isVectorized, "import existing table");
   }
 
+  @Test
+  public void testImportPartitionedOrc() throws Exception {
+    runStatementOnDriver("drop table if exists T");
+    runStatementOnDriver("drop table if exists Tstage");
+    runStatementOnDriver("create table T (a int, b int) partitioned by (p int) 
stored" +
+        " as orc tblproperties('transactional'='true')");
+    //Tstage is the target table
+    runStatementOnDriver("create table Tstage (a int, b int) partitioned by (p 
int) stored" +
+        " as orc tblproperties('transactional'='true')");
+    //this creates an ORC data file with correct schema under table root
+    runStatementOnDriver("insert into Tstage 
values(1,2,10),(3,4,11),(5,6,12)");
+    final int[][] rows = {{3}};
+    //now we have an archive with 3 partitions
+    runStatementOnDriver("export table Tstage to '" + getWarehouseDir() + 
"/1'");
+
+    //load T
+    runStatementOnDriver("import table T from '" + getWarehouseDir() + "/1'");
+    List<String> rs = runStatementOnDriver("select count(*) from T");
+    Assert.assertEquals("Rowcount of imported table", 
TestTxnCommands2.stringifyValues(rows), rs);
+  }
+
   /**
    * test selective partitioned import where target table needs to be created.
    * export is made from acid table so that target table is created as acid
diff --git a/ql/src/test/results/clientpositive/llap/mm_exim.q.out 
b/ql/src/test/results/clientpositive/llap/mm_exim.q.out
index ee6cf06..37d3952 100644
--- a/ql/src/test/results/clientpositive/llap/mm_exim.q.out
+++ b/ql/src/test/results/clientpositive/llap/mm_exim.q.out
@@ -386,7 +386,6 @@ Retention:                  0
 #### A masked pattern was here ####
 Table Type:            MANAGED_TABLE            
 Table Parameters:               
-       COLUMN_STATS_ACCURATE   {\"BASIC_STATS\":\"true\"}
        bucketing_version       2                   
        numFiles                3                   
        numPartitions           3                   

Reply via email to