This is an automated email from the ASF dual-hosted git repository. prozsa pushed a commit to branch branch-4.5.0 in repository https://gitbox.apache.org/repos/asf/impala.git
commit e4b5f36003dffb73256c5e614f88ceb5b64e1972 Author: Riza Suminto <riza.sumi...@cloudera.com> AuthorDate: Mon Feb 10 18:23:11 2025 -0800 IMPALA-13747: Use fresh HS2 client for unique_database fixture Just like IMPALA-13634 bug, unique_database fixture may taint ImpalaTestSuite.client by setting 'sync_ddl=True' option and never cleaning it up for test method usage. This patch fixes unique_database fixture by always creating fresh HS2 client during CREATE DATABASE and DROP DATABASE. Testing: - Caught an assert error at test_set_fallback_db_for_functions Expected: "default.fn() unknown for database default" Actual: "functional.fn() unknown for database functional" In this case, shared ImpalaTestSuite.client may have changed database via ImpalaTestSuite.run_test_case() or ImpalaTestSuite.execute_wrapper() in other test method. Removing unused 'vector' argument somehow fixed the issue. - For both query_test/test_udfs.py and metadata/test_ddl.py: - Fixed flake8 issues and remove unused pytest fixture. - Run and pass the tests in exhaustive exploration. Change-Id: Ib503e829552d436035c57b489ffda0d0299f8405 Reviewed-on: http://gerrit.cloudera.org:8080/22471 Reviewed-by: Riza Suminto <riza.sumi...@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> --- tests/conftest.py | 42 +++++++++++++++---------- tests/metadata/test_ddl.py | 72 +++++++++++++++++++++++-------------------- tests/query_test/test_udfs.py | 41 +++++++++++++----------- 3 files changed, 88 insertions(+), 67 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9366e021c..59d2ebbd6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -83,7 +83,7 @@ def configure_logging(): # Verify that the logging level is set to the correct value. rootLoggerLevel = logging.getLogger().getEffectiveLevel() print("rootLoggerLevel = {0}".format(logging.getLevelName(rootLoggerLevel))) - assert(rootLoggerLevel == logging.INFO) + assert (rootLoggerLevel == logging.INFO) def pytest_addoption(parser): @@ -192,6 +192,12 @@ def pytest_addoption(parser): help="Impala protocol to run test if test does not specify any.") +def assert_impala_test_suite(request): + assert issubclass(request.cls, tests.common.impala_test_suite.ImpalaTestSuite), ( + "This fixture is only applicable to ImpalaTestSuite subclasses." + ) + + def pytest_assertrepr_compare(op, left, right): """ Provides a hook for outputting type-specific assertion messages @@ -353,6 +359,7 @@ def unique_database(request, testid_checksum): assert 'function' == request.scope, ('This fixture must have scope "function" since ' 'the fixture must guarantee unique per-test ' 'databases.') + assert_impala_test_suite(request) db_name_prefix = request.function.__name__ sync_ddl = False @@ -376,11 +383,10 @@ def unique_database(request, testid_checksum): ' test function name or any prefixes for long length or invalid ' 'characters.'.format(db_name)) - def cleanup_database(db_name, must_exist): - request.instance.execute_query_expect_success(request.instance.client, - 'DROP DATABASE {0} `{1}` CASCADE'.format( - "" if must_exist else "IF EXISTS", db_name), - {'sync_ddl': sync_ddl}) + def cleanup_database(client, db_name, must_exist): + result = client.execute('DROP DATABASE {0} `{1}` CASCADE'.format( + "" if must_exist else "IF EXISTS", db_name)) + assert result.success # The database directory may not be removed if there are external tables in the # database when it is dropped. The external locations are not removed by cascade. # These preexisting files/directories can cause errors when tests run repeatedly or @@ -391,21 +397,25 @@ def unique_database(request, testid_checksum): def cleanup(): # Make sure we don't try to drop the current session database + # TODO: clean this up via IMPALA-13758. request.instance.execute_query_expect_success(request.instance.client, "use default") - for db_name in db_names: - cleanup_database(db_name, True) - LOG.info('Dropped database "{0}" for test ID "{1}"'.format( + with request.cls.create_impala_client(protocol=HS2) as client: + client.set_configuration({'sync_ddl': sync_ddl}) + for db_name in db_names: + cleanup_database(client, db_name, True) + LOG.info('Dropped database "{0}" for test ID "{1}"'.format( db_name, str(request.node.nodeid))) request.addfinalizer(cleanup) - for db_name in db_names: - cleanup_database(db_name, False) - request.instance.execute_query_expect_success( - request.instance.client, 'CREATE DATABASE `{0}`'.format(db_name), - {'sync_ddl': sync_ddl}) - LOG.info('Created database "{0}" for test ID "{1}"'.format(db_name, - str(request.node.nodeid))) + with request.cls.create_impala_client(protocol=HS2) as client: + client.set_configuration({'sync_ddl': sync_ddl}) + for db_name in db_names: + cleanup_database(client, db_name, False) + result = client.execute('CREATE DATABASE `{0}`'.format(db_name)) + assert result.success + LOG.info('Created database "{0}" for test ID "{1}"'.format( + db_name, str(request.node.nodeid))) return first_db_name diff --git a/tests/metadata/test_ddl.py b/tests/metadata/test_ddl.py index 782629ac3..c6e64ab22 100644 --- a/tests/metadata/test_ddl.py +++ b/tests/metadata/test_ddl.py @@ -31,8 +31,12 @@ from tests.common.environ import (HIVE_MAJOR_VERSION) from tests.common.file_utils import create_table_from_orc from tests.common.impala_test_suite import LOG from tests.common.parametrize import UniqueDatabase -from tests.common.skip import (SkipIf, SkipIfFS, SkipIfKudu, SkipIfLocal, - SkipIfCatalogV2, SkipIfHive2, SkipIfDockerizedCluster) +from tests.common.skip import ( + SkipIfDockerizedCluster, + SkipIfFS, + SkipIfHive2, + SkipIfKudu, + SkipIfLocal) from tests.common.test_dimensions import create_single_exec_option_dimension from tests.common.test_dimensions import (create_exec_option_dimension, create_client_protocol_dimension, create_exec_option_dimension_from_dict) @@ -56,6 +60,7 @@ def get_trash_path(bucket, path): getpass.getuser(), WAREHOUSE_PREFIX, path)) return '/user/{0}/.Trash/Current/{1}/{2}'.format(getpass.getuser(), bucket, path) + # Validates DDL statements (create, drop) class TestDdlStatements(TestDdlBase): @SkipIfLocal.hdfs_client @@ -129,7 +134,7 @@ class TestDdlStatements(TestDdlBase): self._create_db(unique_database) self.client.execute("create table {0}.t1(i int)".format(unique_database)) self.client.execute("create table {0}.t2(i int)".format(unique_database)) - result = self.client.execute("create external table {0}.t3(i int) " + self.client.execute("create external table {0}.t3(i int) " "location '{1}/{0}/t3/'".format(unique_database, WAREHOUSE)) self.client.execute("drop database {0} cascade".format(unique_database)) assert not self.filesystem_client.exists( @@ -184,7 +189,8 @@ class TestDdlStatements(TestDdlBase): assert len(self.filesystem_client.ls( "{1}/{0}.db/t2/p=1".format(unique_database, WAREHOUSE))) == 1 - # Truncating the table removes the data files and preserves the partition's directory + # Truncating the table removes the data files and preserves the partition's + # directory self.client.execute("truncate table {0}.t2".format(unique_database)) assert self.filesystem_client.exists( "{1}/{0}.db/t2/p=1".format(unique_database, WAREHOUSE)) @@ -208,7 +214,7 @@ class TestDdlStatements(TestDdlBase): self.run_test_case('QueryTest/create-database', vector, use_db=unique_database, multiple_impalad=self._use_multiple_impalad(vector)) - def test_comment_on_database(self, vector, unique_database): + def test_comment_on_database(self, unique_database): comment = self._get_db_comment(unique_database) assert '' == comment @@ -220,7 +226,8 @@ class TestDdlStatements(TestDdlBase): comment = self._get_db_comment(unique_database) assert '' == comment - self.client.execute("comment on database {0} is '\\'comment\\''".format(unique_database)) + self.client.execute("comment on database {0} is '\\'comment\\''".format( + unique_database)) comment = self._get_db_comment(unique_database) assert "\\'comment\\'" == comment @@ -228,7 +235,7 @@ class TestDdlStatements(TestDdlBase): comment = self._get_db_comment(unique_database) assert '' == comment - def test_alter_database_set_owner(self, vector, unique_database): + def test_alter_database_set_owner(self, unique_database): self.client.execute("alter database {0} set owner user foo_user".format( unique_database)) properties = self._get_db_owner_properties(unique_database) @@ -241,7 +248,7 @@ class TestDdlStatements(TestDdlBase): assert len(properties) == 1 assert {'foo_role': 'ROLE'} == properties - def test_metadata_after_alter_database(self, vector, unique_database): + def test_metadata_after_alter_database(self, unique_database): self.client.execute("create table {0}.tbl (i int)".format(unique_database)) self.client.execute("create function {0}.f() returns int " "location '{1}/libTestUdfs.so' symbol='NoArgs'" @@ -255,7 +262,7 @@ class TestDdlStatements(TestDdlBase): unique_database)).get_data() assert "INT\tf()\tNATIVE\ttrue" == func_names - def test_alter_table_set_owner(self, vector, unique_database): + def test_alter_table_set_owner(self, unique_database): table_name = "{0}.test_owner_tbl".format(unique_database) self.client.execute("create table {0}(i int)".format(table_name)) self.client.execute("alter table {0} set owner user foo_user".format(table_name)) @@ -266,7 +273,7 @@ class TestDdlStatements(TestDdlBase): owner = self._get_table_or_view_owner(table_name) assert ('foo_role', 'ROLE') == owner - def test_alter_view_set_owner(self, vector, unique_database): + def test_alter_view_set_owner(self, unique_database): view_name = "{0}.test_owner_tbl".format(unique_database) self.client.execute("create view {0} as select 1".format(view_name)) self.client.execute("alter view {0} set owner user foo_user".format(view_name)) @@ -333,7 +340,7 @@ class TestDdlStatements(TestDdlBase): self.run_test_case('QueryTest/kudu_create', vector, use_db=unique_database, multiple_impalad=self._use_multiple_impalad(vector)) - def test_comment_on_table(self, vector, unique_database): + def test_comment_on_table(self, unique_database): table = '{0}.comment_table'.format(unique_database) self.client.execute("create table {0} (i int)".format(table)) @@ -356,7 +363,7 @@ class TestDdlStatements(TestDdlBase): comment = self._get_table_or_view_comment(table) assert comment is None - def test_comment_on_view(self, vector, unique_database): + def test_comment_on_view(self, unique_database): view = '{0}.comment_view'.format(unique_database) self.client.execute("create view {0} as select 1".format(view)) @@ -379,7 +386,7 @@ class TestDdlStatements(TestDdlBase): comment = self._get_table_or_view_comment(view) assert comment is None - def test_comment_on_column(self, vector, unique_database): + def test_comment_on_column(self, unique_database): table = "{0}.comment_table".format(unique_database) self.client.execute("create table {0} (i int) partitioned by (j int)".format(table)) @@ -431,7 +438,7 @@ class TestDdlStatements(TestDdlBase): assert "" == comment @UniqueDatabase.parametrize(sync_ddl=True) - def test_sync_ddl_drop(self, vector, unique_database): + def test_sync_ddl_drop(self, unique_database): """Verifies the catalog gets updated properly when dropping objects with sync_ddl enabled""" self.client.set_configuration({'sync_ddl': 1}) @@ -479,7 +486,7 @@ class TestDdlStatements(TestDdlBase): use_db=unique_database, multiple_impalad=self._use_multiple_impalad(vector)) @SkipIfLocal.hdfs_client - def test_drop_partition_with_purge(self, vector, unique_database): + def test_drop_partition_with_purge(self, unique_database): """Verfies whether alter <tbl> drop partition purge actually skips trash""" self.client.execute( "create table {0}.t1(i int) partitioned by (j int)".format(unique_database)) @@ -497,8 +504,8 @@ class TestDdlStatements(TestDdlBase): assert self.filesystem_client.exists('{}/t1/j=1/j1.txt'.format(trash)) assert self.filesystem_client.exists('{}/t1/j=1'.format(trash)) # Drop the partition (with purge) and make sure it doesn't exist in trash - self.client.execute("alter table {0}.t1 drop partition(j=2) purge".\ - format(unique_database)); + self.client.execute("alter table {0}.t1 drop partition(j=2) purge".format( + unique_database)) if not IS_S3 and not IS_ADLS: # In S3, deletes are eventual. So even though we dropped the partition, the files # belonging to this partition may still be visible for some unbounded time. This @@ -518,7 +525,7 @@ class TestDdlStatements(TestDdlBase): multiple_impalad=self._use_multiple_impalad(vector)) @UniqueDatabase.parametrize() - def test_view_hints(self, vector, unique_database): + def test_view_hints(self, unique_database): # Test that plan hints are stored in the view's comment field; this should work # regardless of how Hive formats the output. Getting this to work with the # automated test case runner is rather difficult, so verify directly. There @@ -530,7 +537,7 @@ class TestDdlStatements(TestDdlBase): inner join /* +shuffle */ functional.alltypessmall c on b.id = c.id """.format(unique_database)) results = self.execute_query("describe formatted %s.hints_test" % unique_database) - sj, bc, shuf = 0,0,0 + sj, bc, shuf = 0, 0, 0 for row in results.data: sj += '-- +straight_join' in row bc += '-- +broadcast' in row @@ -547,7 +554,7 @@ class TestDdlStatements(TestDdlBase): # Test the plan to make sure hints were applied correctly plan = self.execute_query("explain select * from %s.hints_test" % unique_database, - query_options={'explain_level':0}) + query_options={'explain_level': 0}) plan_match = """PLAN-ROOT SINK 08:EXCHANGE [UNPARTITIONED] 04:HASH JOIN [INNER JOIN, PARTITIONED] @@ -580,7 +587,7 @@ class TestDdlStatements(TestDdlBase): try: result = self.execute_query_expect_success( client, "describe formatted %s" % view_name) - exp_line = [l for l in result.data if 'View Expanded' in l][0] + exp_line = [line for line in result.data if 'View Expanded' in line][0] except ImpalaBeeswaxException as e: # In non-SYNC_DDL tests, it's OK to get a "missing view" type error # until the metadata propagates. @@ -591,7 +598,6 @@ class TestDdlStatements(TestDdlBase): finally: client.close() - def test_views_describe(self, vector, unique_database): # IMPALA-6896: Tests that altered views can be described by all impalads. impala_cluster = ImpalaCluster.get_e2e_test_cluster() @@ -617,14 +623,13 @@ class TestDdlStatements(TestDdlBase): finally: first_client.close() - @UniqueDatabase.parametrize(sync_ddl=True) def test_functions_ddl(self, vector, unique_database): self.run_test_case('QueryTest/functions-ddl', vector, use_db=unique_database, multiple_impalad=self._use_multiple_impalad(vector)) @SkipIfLocal.hdfs_client - def test_create_alter_bulk_partition(self, vector, unique_database): + def test_create_alter_bulk_partition(self, unique_database): # Change the scale depending on the exploration strategy, with 50 partitions this # test runs a few minutes, with 10 partitions it takes ~50s for two configurations. num_parts = 50 if self.exploration_strategy() == 'exhaustive' else 10 @@ -667,7 +672,7 @@ class TestDdlStatements(TestDdlBase): assert '1' == self.execute_scalar("select count(*) from {0}".format(fq_tbl_name)) @SkipIfLocal.hdfs_client - def test_alter_table_set_fileformat(self, vector, unique_database): + def test_alter_table_set_fileformat(self, unique_database): # Tests that SET FILEFORMAT clause is set for ALTER TABLE ADD PARTITION statement fq_tbl_name = unique_database + ".p_fileformat" self.client.execute( @@ -689,7 +694,7 @@ class TestDdlStatements(TestDdlBase): assert 1 == len([line for line in result.data if line.find("PARQUET") != -1]) assert 2 == len([line for line in result.data if line.find("ORC") != -1]) - def test_alter_table_create_many_partitions(self, vector, unique_database): + def test_alter_table_create_many_partitions(self, unique_database): """ Checks that creating more partitions than the MAX_PARTITION_UPDATES_PER_RPC batch size works, in that it creates all the underlying partitions. @@ -709,7 +714,7 @@ class TestDdlStatements(TestDdlBase): assert list(map(int, PARTITION_RE.findall(str(partitions)))) == \ list(range(MAX_PARTITION_UPDATES_PER_RPC + 2)) - def test_create_alter_tbl_properties(self, vector, unique_database): + def test_create_alter_tbl_properties(self, unique_database): fq_tbl_name = unique_database + ".test_alter_tbl" # Specify TBLPROPERTIES and SERDEPROPERTIES at CREATE time @@ -756,7 +761,7 @@ class TestDdlStatements(TestDdlBase): assert properties[''] == '' @SkipIfHive2.acid - def test_create_insertonly_tbl(self, vector, unique_database): + def test_create_insertonly_tbl(self, unique_database): insertonly_tbl = unique_database + ".test_insertonly" self.client.execute("""create table {0} (coli int) stored as parquet tblproperties( 'transactional'='true', 'transactional_properties'='insert_only')""" @@ -764,7 +769,7 @@ class TestDdlStatements(TestDdlBase): properties = self._get_tbl_properties(insertonly_tbl) assert properties['OBJCAPABILITIES'] == 'HIVEMANAGEDINSERTREAD,HIVEMANAGEDINSERTWRITE' - def test_alter_tbl_properties_reload(self, vector, unique_database): + def test_alter_tbl_properties_reload(self, unique_database): # IMPALA-8734: Force a table schema reload when setting table properties. tbl_name = "test_tbl" self.execute_query_expect_success(self.client, "create table {0}.{1} (c1 string)" @@ -792,7 +797,7 @@ class TestDdlStatements(TestDdlBase): self.run_test_case('QueryTest/partition-ddl-predicates-hdfs-only', vector, use_db=unique_database, multiple_impalad=self._use_multiple_impalad(vector)) - def test_create_table_file_format(self, vector, unique_database): + def test_create_table_file_format(self, unique_database): # When default_file_format query option is not specified, the default table file # format is TEXT. text_table = "{0}.text_tbl".format(unique_database) @@ -826,7 +831,7 @@ class TestDdlStatements(TestDdlBase): assert any("ORC" in x for x in result.data) @SkipIfHive2.acid - def test_create_table_transactional_type(self, vector, unique_database): + def test_create_table_transactional_type(self, unique_database): # When default_transactional_type query option is not specified, the transaction # related table properties are not set. non_acid_table = "{0}.non_acid_tbl".format(unique_database) @@ -876,7 +881,7 @@ class TestDdlStatements(TestDdlBase): assert "transactional" not in props assert "transactional_properties" not in props - def test_kudu_column_comment(self, vector, unique_database): + def test_kudu_column_comment(self, unique_database): table = "{0}.kudu_table0".format(unique_database) self.client.execute("create table {0}(x int comment 'x' primary key) \ stored as kudu".format(table)) @@ -925,6 +930,7 @@ class TestDdlStatements(TestDdlBase): self.run_test_case('QueryTest/describe-materialized-view', vector, use_db=unique_database, multiple_impalad=self._use_multiple_impalad(vector)) + # IMPALA-10811: RPC to submit query getting stuck for AWS NLB forever # Test HS2, Beeswax and HS2-HTTP three clients. class TestAsyncDDL(TestDdlBase): @@ -942,7 +948,7 @@ class TestAsyncDDL(TestDdlBase): def test_async_ddl(self, vector, unique_database): self.run_test_case('QueryTest/async_ddl', vector, use_db=unique_database) - def test_async_ddl_with_JDBC(self, vector, unique_database): + def test_async_ddl_with_JDBC(self, unique_database): self.exec_with_jdbc("drop table if exists {0}.test_table".format(unique_database)) self.exec_with_jdbc_and_compare_result( "create table {0}.test_table(a int)".format(unique_database), diff --git a/tests/query_test/test_udfs.py b/tests/query_test/test_udfs.py index a7e93fcbe..31bcb5873 100644 --- a/tests/query_test/test_udfs.py +++ b/tests/query_test/test_udfs.py @@ -28,13 +28,13 @@ from tests.common.impala_cluster import ImpalaCluster from tests.common.impala_test_suite import ImpalaTestSuite from tests.common.skip import SkipIfLocal from tests.common.test_dimensions import ( - create_exec_option_dimension, create_exec_option_dimension_from_dict, create_uncompressed_text_dimension) from tests.util.calculation_util import get_random_id from tests.util.filesystem_utils import get_fs_path, WAREHOUSE from tests.verifiers.metric_verifier import MetricVerifier + class TestUdfBase(ImpalaTestSuite): """ Base class with utility functions for testing UDFs. @@ -109,12 +109,14 @@ returns date intermediate date location '{location}' init_fn='AggDateIntermediateInit' update_fn='AggDateIntermediateUpdate' merge_fn='AggDateIntermediateMerge' finalize_fn='AggDateIntermediateFinalize'; -create aggregate function {database}.agg_string_intermediate(decimal(20,10), bigint, string) +create aggregate function {database}.agg_string_intermediate( + decimal(20,10), bigint, string) returns decimal(20,0) intermediate string location '{location}' init_fn='AggStringIntermediateInit' update_fn='AggStringIntermediateUpdate' merge_fn='AggStringIntermediateMerge' finalize_fn='AggStringIntermediateFinalize'; -create aggregate function {database}.agg_binary_intermediate(decimal(20,10), bigint, binary) +create aggregate function {database}.agg_binary_intermediate( + decimal(20,10), bigint, binary) returns decimal(20,0) intermediate binary location '{location}' init_fn='AggStringIntermediateInit' update_fn='AggStringIntermediateUpdate' merge_fn='AggStringIntermediateMerge' finalize_fn='AggStringIntermediateFinalize'; @@ -234,7 +236,8 @@ create function {database}.count_rows() returns bigint location '{location}' symbol='Count' prepare_fn='CountPrepare' close_fn='CountClose'; create function {database}.constant_arg(int) returns int -location '{location}' symbol='ConstantArg' prepare_fn='ConstantArgPrepare' close_fn='ConstantArgClose'; +location '{location}' symbol='ConstantArg' prepare_fn='ConstantArgPrepare' +close_fn='ConstantArgClose'; create function {database}.validate_open(int) returns boolean location '{location}' symbol='ValidateOpen' @@ -271,11 +274,12 @@ create function {database}.twenty_args(int, int, int, int, int, int, int, int, i int, int, int, int, int, int, int, int, int, int) returns int location '{location}' symbol='TwentyArgs'; -create function {database}.twenty_one_args(int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int) returns int +create function {database}.twenty_one_args(int, int, int, int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, int, int, int) returns int location '{location}' symbol='TwentyOneArgs'; """ + class TestUdfExecution(TestUdfBase): """Test execution of UDFs with a combination of different query options.""" @classmethod @@ -286,10 +290,10 @@ class TestUdfExecution(TestUdfBase): def add_test_dimensions(cls): super(TestUdfExecution, cls).add_test_dimensions() cls.ImpalaTestMatrix.add_dimension( - create_exec_option_dimension_from_dict({"disable_codegen" : [False, True], - "disable_codegen_rows_threshold" : [0], - "exec_single_node_rows_threshold" : [0,100], - "enable_expr_rewrites" : [False, True]})) + create_exec_option_dimension_from_dict({"disable_codegen": [False, True], + "disable_codegen_rows_threshold": [0], + "exec_single_node_rows_threshold": [0, 100], + "enable_expr_rewrites": [False, True]})) # There is no reason to run these tests using all dimensions. cls.ImpalaTestMatrix.add_dimension( create_uncompressed_text_dimension(cls.get_workload())) @@ -448,7 +452,7 @@ class TestUdfTargeted(TestUdfBase): cls.ImpalaTestMatrix.add_dimension( create_uncompressed_text_dimension(cls.get_workload())) - def test_udf_invalid_symbol(self, vector, unique_database): + def test_udf_invalid_symbol(self, unique_database): """ IMPALA-1642: Impala crashes if the symbol for a Hive UDF doesn't exist Invalid symbols are checked at UDF creation time.""" src_udf_path = os.path.join( @@ -467,7 +471,7 @@ class TestUdfTargeted(TestUdfBase): ex = self.execute_query_expect_failure(self.client, create_fn_stmt) assert "ClassNotFoundException" in str(ex) - def test_hidden_symbol(self, vector, unique_database): + def test_hidden_symbol(self, unique_database): """Test that symbols in the test UDFs are hidden by default and that therefore they cannot be used as a UDF entry point.""" symbol = "_Z16UnexportedSymbolPN10impala_udf15FunctionContextE" @@ -478,7 +482,7 @@ class TestUdfTargeted(TestUdfBase): assert "Could not find symbol '{0}'".format(symbol) in str(ex), str(ex) # IMPALA-8196: IR UDFs ignore whether symbol is hidden or not. Exercise the current # behaviour, where the UDF can be created and executed. - result = self.execute_query_expect_success(self.client, """ + self.execute_query_expect_success(self.client, """ create function `{0}`.unexported() returns BIGINT LOCATION '{1}' SYMBOL='{2}'""".format( unique_database, get_fs_path('/test-warehouse/test-udfs.ll'), symbol)) @@ -528,7 +532,8 @@ class TestUdfTargeted(TestUdfBase): assert "Failed to get file info" in str(e) def test_libs_with_same_filenames(self, vector, unique_database): - self.run_test_case('QueryTest/libs_with_same_filenames', vector, use_db=unique_database) + self.run_test_case('QueryTest/libs_with_same_filenames', vector, + use_db=unique_database) def test_udf_update_via_drop(self, vector, unique_database): """Test updating the UDF binary without restarting Impala. Dropping @@ -638,7 +643,7 @@ class TestUdfTargeted(TestUdfBase): assert results.success assert len(results.data) == 9999 - def test_udf_profile(self, vector, unique_database): + def test_udf_profile(self, unique_database): """Test to validate that explain plans and runtime profiles contain information about any custom UDFs used in an Impala query.""" self.client.execute( @@ -649,13 +654,13 @@ class TestUdfTargeted(TestUdfBase): "select {0}.hive_substring(string_col, 1), {0}.hive_substring(string_col, 2) " "from functional.alltypes limit 10".format(unique_database)).runtime_profile - assert re.search("output exprs.*hive_substring.*/\* JAVA UDF \*/", profile) + assert re.search(r"output exprs.*hive_substring.*/\* JAVA UDF \*/", profile) # Ensure that hive_substring only shows up once in the list of UDFs. assert re.search( - "User Defined Functions \(UDFs\): {0}\.hive_substring\s*[\r\n]".format( + r"User Defined Functions \(UDFs\): {0}\.hive_substring\s*[\r\n]".format( unique_database), profile) - def test_set_fallback_db_for_functions(self, vector, unique_database): + def test_set_fallback_db_for_functions(self, unique_database): """IMPALA-11728: Set fallback database for functions.""" create_function_stmt = "create function `{0}`.fn() returns int "\ "location '{1}/libTestUdfs.so' symbol='NoArgs'".format(unique_database,