This is an automated email from the ASF dual-hosted git repository. prozsa pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit f2acd2381ffb3d33f5789bc6086b7d821bad4561 Author: Riza Suminto <[email protected]> AuthorDate: Tue May 6 18:32:34 2025 -0700 IMPALA-14039: __restore_query_options should unset query option ImpalaTestSuite.__restore_query_options() attempt to restore client's configuration with what it understand as the "default" query option. Since IMPALA-13930, ImpalaConnection.get_default_configuration() parse the default query option from TQueryOption fields. Therefore, it might not respect server's default that comes from --default_query_options flag. ImpalaTestSuite.__restore_query_options() should simply unset any configuration that previously set by running SET query like this: SET query_option=""; This patch also change execute_query_using_vector() to simply unset client's configuration. Follow up cleanup will be tracked through IMPALA-14060. Testing: Run and pass test_queries.py::TestQueries. Change-Id: I884986b9ecbcabf0b34a7346220e6ea4142ca923 Reviewed-on: http://gerrit.cloudera.org:8080/22862 Reviewed-by: Impala Public Jenkins <[email protected]> Reviewed-by: Jason Fehr <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- tests/common/impala_connection.py | 11 +++++++---- tests/common/impala_test_suite.py | 27 +++------------------------ 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/tests/common/impala_connection.py b/tests/common/impala_connection.py index 6d6f6d338..09568bcad 100644 --- a/tests/common/impala_connection.py +++ b/tests/common/impala_connection.py @@ -230,9 +230,12 @@ class ImpalaConnection(with_metaclass(abc.ABCMeta, object)): pass def get_default_configuration(self): - """Return the default configuration for the connection, before any modifications are - made to the session state. Returns a map with the config variable as the key and a - string representation of the default value as the value.""" + """Return the default configuration that is known from TQueryOption attributes. + Note that this might not be the server default. Server default can be different + depending on its --default_query_options flag value. + Returns a map with the config variable as the key and a string representation of + the default value as the value. + IMPALA-14060: Remove this and related functions.""" return DEFAULT_QUERY_OPTIONS.copy() @abc.abstractmethod @@ -631,7 +634,7 @@ class ImpylaHS2Connection(ImpalaConnection): # value must be parsed to string. name = name.lower() value = str(value) - if self.__query_options.get(name) != value: + if self.__query_options.get(name, "") != value: self.__query_options[name] = value if is_log_sql: self.log_client("\n\nset {0}={1};\n".format(name, value)) diff --git a/tests/common/impala_test_suite.py b/tests/common/impala_test_suite.py index bf6329ebd..996822483 100644 --- a/tests/common/impala_test_suite.py +++ b/tests/common/impala_test_suite.py @@ -265,9 +265,6 @@ class ImpalaTestSuite(BaseTestSuite): cls.hs2_http_client = None cls.hive_client = None cls.hive_transport = None - - # Default query options are populated on demand. - cls.default_query_options = {} cls.impalad_test_service = cls.create_impala_service() # Override the shell history path so that commands run by any tests @@ -547,23 +544,10 @@ class ImpalaTestSuite(BaseTestSuite): """ Restore the list of modified query options to their default values. """ - # Populate the default query option if it's empty. - if not self.default_query_options: - query_options = impalad_client.get_default_configuration() - for key, value in query_options.items(): - self.default_query_options[key.lower()] = value # Restore all the changed query options. for query_option in query_options_changed: query_option = query_option.lower() - if query_option not in self.default_query_options: - continue - default_val = self.default_query_options[query_option] - # No need to quote default_val because get_default_configuration() returns - # map values that already contain double quote if needed - # (see collect_default_query_options() in impala_connection.py). - # The "restore option" comment is there to differentiate between SET issued - # by test method and SET issued by this method. - query_str = "SET {0}={1}; -- restore option".format(query_option, default_val) + query_str = 'SET {0}=""'.format(query_option) try: impalad_client.execute(query_str) except Exception as e: @@ -1212,13 +1196,8 @@ class ImpalaTestSuite(BaseTestSuite): result = self.execute_query_using_client(client, query, vector) # Restore client configuration before returning. modified_configs = vector.get_exec_option_dict().keys() - options_to_restore = dict() - for name, val in client.get_default_configuration().items(): - lower_name = name.lower() - if lower_name in modified_configs: - options_to_restore[lower_name] = val - if options_to_restore: - client.set_configuration(options_to_restore) + for name in modified_configs: + client.set_configuration_option(name, "") return result @execute_wrapper
