You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2020/04/01 14:49:07 UTC

[impala] 01/02: IMPALA-9451: Fix test_hive_text_codec_interop.py failure in CDP build

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

joemcdonnell pushed a commit to branch branch-3.4.0
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 946fa636fc05f3f6b32f52291edc1ea4105a2b0d
Author: xiaomeng <xi...@cloudera.com>
AuthorDate: Fri Mar 20 17:30:54 2020 -0700

    IMPALA-9451: Fix test_hive_text_codec_interop.py failure in CDP build
    
    In CDP build we use Hive3 which has a bug HIVE-22371 (CTAS puts
    files in the wrong place). It causes failure of newly added test as
    CTAS creates empty table.
    
    Workaround by explicitly creating an external table when hive
    version >= 3.
    
    Tested:
    Run this test in newest CDP build using job
    impala-private-basic-parameterized.
    
    Change-Id: Ief8e583aae82f548754f41e07efac5d7bca4b930
    Reviewed-on: http://gerrit.cloudera.org:8080/15520
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
    (cherry picked from commit 66de7808c7e1b017e442939d6dd6fd58017e4a1b)
---
 tests/custom_cluster/test_hive_text_codec_interop.py | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/custom_cluster/test_hive_text_codec_interop.py b/tests/custom_cluster/test_hive_text_codec_interop.py
index daaad8f..556a0e0 100644
--- a/tests/custom_cluster/test_hive_text_codec_interop.py
+++ b/tests/custom_cluster/test_hive_text_codec_interop.py
@@ -20,6 +20,7 @@
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
+from tests.common.environ import HIVE_MAJOR_VERSION
 from tests.common.skip import SkipIfS3
 from tests.common.test_dimensions import create_exec_option_dimension
 from tests.common.test_result_verifier import verify_query_result_is_equal
@@ -66,6 +67,15 @@ class TestTextInterop(CustomClusterTestSuite):
         "insert into {0}(id) values (7777), (8888), (9999), (11111), (22222), (33333)"
         .format(source_table))
 
+    # For Hive 3+, workaround for HIVE-22371 (CTAS puts files in the wrong place) by
+    # explicitly creating an external table so that files are in the external warehouse
+    # directory. Use external.table.purge=true so that it is equivalent to a Hive 2
+    # managed table. Hive 2 stays the same.
+    external = ""
+    tblproperties = ""
+    if HIVE_MAJOR_VERSION >= 3:
+      external = "external"
+      tblproperties = "TBLPROPERTIES('external.table.purge'='TRUE')"
     # Loop through the compression codecs and run interop tests.
     for codec in TEXT_CODECS:
       # Write data in Hive and read from Impala
@@ -83,8 +93,13 @@ class TestTextInterop(CustomClusterTestSuite):
       self.run_stmt_in_hive("drop table if exists {0}".format(hive_table))
       self.run_stmt_in_hive("set hive.exec.compress.output=true;\
           set mapreduce.output.fileoutputformat.compress.codec={0};\
-          create table {1} stored as textfile as select * from {2}"
-          .format(switcher.get(codec, 'Invalid codec'), hive_table, source_table))
+          create {1} table {2} stored as textfile {3} as select * from {4}"
+          .format(switcher.get(codec, 'Invalid codec'), external, hive_table,
+          tblproperties, source_table))
+
+      # Make sure hive CTAS table is not empty
+      assert self.run_stmt_in_hive("select count(*) from {0}".format(
+          hive_table)).split("\n")[1] != "0", "CTAS created Hive table is empty."
 
       # Make sure Impala's metadata is in sync.
       if cluster_properties.is_catalog_v2_cluster():