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

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

commit fdc43466350db4437b3e917d4ff24dac58af63c3
Author: stiga-huang <[email protected]>
AuthorDate: Wed Jan 1 09:22:52 2025 +0800

    IMPALA-13634: ImpalaTestSuite.cleanup_db() should use its own client
    
    ImpalaTestSuite.cleanup_db(cls, db_name, sync_ddl=1) is used to drop the
    entire db. Currently it uses cls.client and sets sync_ddl based on the
    parameter. This clears all the query options of cls.client and makes it
    always run with the same sync_ddl value unless the test code explicitly
    set query options again.
    
    This patch changes cleanup_db() to use a dedicated client. Tested with
    some tests that uses this method and see performance improvement:
    
    TestName                                                                    
                         Before After
    metadata/test_explain.py::TestExplainEmptyPartition                         
                            52s   9s
    
query_test/test_insert_behaviour.py::TestInsertBehaviour::test_insert_select_with_empty_resultset
       62s   15s
    
metadata/test_metadata_query_statements.py::TestMetadataQueryStatements::test_describe_db
 (exhaustive)  160s  25s
    
    Change-Id: Icb01665bc18d24e2fce4383df87c4607cf4562f1
    Reviewed-on: http://gerrit.cloudera.org:8080/22286
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 tests/common/impala_test_suite.py                | 10 +++++++---
 tests/metadata/test_compute_stats.py             |  2 +-
 tests/metadata/test_metadata_query_statements.py | 14 +++++++-------
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/tests/common/impala_test_suite.py 
b/tests/common/impala_test_suite.py
index 29456c974..c7f9be133 100644
--- a/tests/common/impala_test_suite.py
+++ b/tests/common/impala_test_suite.py
@@ -427,9 +427,13 @@ class ImpalaTestSuite(BaseTestSuite):
 
   @classmethod
   def cleanup_db(cls, db_name, sync_ddl=1):
-    cls.client.execute("use default")
-    cls.client.set_configuration({'sync_ddl': sync_ddl})
-    cls.client.execute("drop database if exists `" + db_name + "` cascade")
+    # Create a new client to avoid polluting query options of existing clients.
+    client = cls.create_impala_client()
+    client.set_configuration({'sync_ddl': sync_ddl})
+    try:
+      client.execute("drop database if exists `" + db_name + "` cascade")
+    finally:
+      client.close()
 
   def __restore_query_options(self, query_options_changed, impalad_client):
     """
diff --git a/tests/metadata/test_compute_stats.py 
b/tests/metadata/test_compute_stats.py
index 3ec53fdb6..93b815f2d 100644
--- a/tests/metadata/test_compute_stats.py
+++ b/tests/metadata/test_compute_stats.py
@@ -107,7 +107,7 @@ class TestComputeStats(ImpalaTestSuite):
     try:
       self.run_test_case('QueryTest/compute-stats-keywords', vector)
     finally:
-      self.cleanup_db("parquet")
+      self.cleanup_db("parquet", sync_ddl=0)
 
   def test_compute_stats_compression_codec(self, vector, unique_database):
     """IMPALA-8254: Tests that running compute stats with compression_codec set
diff --git a/tests/metadata/test_metadata_query_statements.py 
b/tests/metadata/test_metadata_query_statements.py
index d94698551..89eea1a4e 100644
--- a/tests/metadata/test_metadata_query_statements.py
+++ b/tests/metadata/test_metadata_query_statements.py
@@ -196,10 +196,10 @@ class TestMetadataQueryStatements(ImpalaTestSuite):
       self.__test_describe_db_cleanup()
 
   def __test_describe_db_cleanup(self):
-    self.cleanup_db('hive_test_desc_db')
-    self.cleanup_db('hive_test_desc_db2')
-    self.cleanup_db('impala_test_desc_db1')
-    self.cleanup_db('impala_test_desc_db2')
-    self.cleanup_db('impala_test_desc_db3')
-    self.cleanup_db('impala_test_desc_db4')
-    self.cleanup_db('impala_test_desc_db5')
+    self.cleanup_db('hive_test_desc_db', sync_ddl=0)
+    self.cleanup_db('hive_test_desc_db2', sync_ddl=0)
+    self.cleanup_db('impala_test_desc_db1', sync_ddl=0)
+    self.cleanup_db('impala_test_desc_db2', sync_ddl=0)
+    self.cleanup_db('impala_test_desc_db3', sync_ddl=0)
+    self.cleanup_db('impala_test_desc_db4', sync_ddl=0)
+    self.cleanup_db('impala_test_desc_db5', sync_ddl=0)

Reply via email to