diff --git a/src/databricks/labs/pytester/fixtures/catalog.py b/src/databricks/labs/pytester/fixtures/catalog.py index 895427a..724ca1b 100644 --- a/src/databricks/labs/pytester/fixtures/catalog.py +++ b/src/databricks/labs/pytester/fixtures/catalog.py @@ -118,8 +118,7 @@ def create( # pylint: disable=too-many-locals,too-many-arguments,too-many-state schema = make_schema(catalog_name=catalog_name) catalog_name = schema.catalog_name schema_name = schema.name - if name is None: - name = f"ucx_T{make_random(4)}".lower() + name = name or f"dummy_t{make_random(4).lower()}" table_type: TableType | None = None data_source_format = None storage_location = None @@ -140,7 +139,7 @@ def create( # pylint: disable=too-many-locals,too-many-arguments,too-many-state table_type = TableType.EXTERNAL # pylint: disable=redefined-variable-type data_source_format = DataSourceFormat.JSON # DBFS locations are not purged; no suffix necessary. - storage_location = f"dbfs:/tmp/ucx_test_{make_random(4)}" + storage_location = f"dbfs:/tmp/{name}" if columns is None: select = "*" else: @@ -264,8 +263,7 @@ def test_catalog_fixture(make_catalog, make_schema, make_table): """ def create(*, catalog_name: str = "hive_metastore", name: str | None = None) -> SchemaInfo: - if name is None: - name = f"dummy_S{make_random(4)}".lower() + name = name or f"dummy_s{make_random(4)}".lower() full_name = f"{catalog_name}.{name}".lower() sql_backend.execute(f"CREATE SCHEMA {full_name} WITH DBPROPERTIES (RemoveAfter={watchdog_remove_after})") schema_info = SchemaInfo(catalog_name=catalog_name, name=name, full_name=full_name) @@ -301,7 +299,7 @@ def test_catalog_fixture(make_catalog, make_schema, make_table): """ def create(*, name: str | None = None) -> CatalogInfo: - name = name or f"dummy_C{make_random(4)}".lower() + name = name or f"dummy_c{make_random(4)}".lower() catalog_info = ws.catalogs.create(name=name, properties={"RemoveAfter": watchdog_remove_after}) if isinstance(catalog_info, Mock): catalog_info.name = name @@ -353,8 +351,7 @@ def create( catalog_name = schema.catalog_name schema_name = schema.name - if name is None: - name = f"ucx_t{make_random(4).lower()}" + name = name or f"dummy_f{make_random(4)}".lower() # Note: the Watchdog does not explicitly scan for functions; they are purged along with their parent schema. # As such the function can't be marked (and doesn't need to be if the schema as marked) for purge protection. diff --git a/src/databricks/labs/pytester/fixtures/redash.py b/src/databricks/labs/pytester/fixtures/redash.py index 95437ca..89511d4 100644 --- a/src/databricks/labs/pytester/fixtures/redash.py +++ b/src/databricks/labs/pytester/fixtures/redash.py @@ -54,7 +54,7 @@ def create(sql_query: str | None = None, **kwargs) -> LegacyQuery: query_name = f"dummy_query_Q{make_random(4)}" query = ws.queries_legacy.create( name=query_name, - description="TEST QUERY FOR UCX", + description="Test query", query=sql_query, tags=tags, ) diff --git a/tests/unit/fixtures/test_catalog.py b/tests/unit/fixtures/test_catalog.py index fcd4ab0..105cac8 100644 --- a/tests/unit/fixtures/test_catalog.py +++ b/tests/unit/fixtures/test_catalog.py @@ -12,18 +12,18 @@ def test_make_table_no_args(): assert table_info == TableInfo( catalog_name='hive_metastore', schema_name='dummy_srandom', - name='ucx_trandom', + name='dummy_trandom', table_type=TableType.MANAGED, data_source_format=DataSourceFormat.DELTA, - full_name='hive_metastore.dummy_srandom.ucx_trandom', - storage_location='dbfs:/user/hive/warehouse/dummy_srandom/ucx_trandom', + full_name='hive_metastore.dummy_srandom.dummy_trandom', + storage_location='dbfs:/user/hive/warehouse/dummy_srandom/dummy_trandom', properties={'RemoveAfter': '2024091313'}, ) assert ctx['sql_backend'].queries == [ 'CREATE SCHEMA hive_metastore.dummy_srandom WITH DBPROPERTIES (RemoveAfter=2024091313)', - "CREATE TABLE hive_metastore.dummy_srandom.ucx_trandom (id INT, value STRING) TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", - 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.ucx_trandom', + "CREATE TABLE hive_metastore.dummy_srandom.dummy_trandom (id INT, value STRING) TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", + 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.dummy_trandom', 'DROP SCHEMA IF EXISTS hive_metastore.dummy_srandom CASCADE', ] @@ -34,18 +34,18 @@ def test_make_view(): assert table_info == TableInfo( catalog_name='hive_metastore', schema_name='dummy_srandom', - name='ucx_trandom', + name='dummy_trandom', table_type=TableType.VIEW, - full_name='hive_metastore.dummy_srandom.ucx_trandom', + full_name='hive_metastore.dummy_srandom.dummy_trandom', properties={'RemoveAfter': '2024091313'}, view_definition='SELECT 1', ) assert ctx['sql_backend'].queries == [ 'CREATE SCHEMA hive_metastore.dummy_srandom WITH DBPROPERTIES (RemoveAfter=2024091313)', - "CREATE VIEW hive_metastore.dummy_srandom.ucx_trandom AS SELECT 1", - "ALTER VIEW hive_metastore.dummy_srandom.ucx_trandom SET TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", - 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.ucx_trandom', + "CREATE VIEW hive_metastore.dummy_srandom.dummy_trandom AS SELECT 1", + "ALTER VIEW hive_metastore.dummy_srandom.dummy_trandom SET TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", + 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.dummy_trandom', 'DROP SCHEMA IF EXISTS hive_metastore.dummy_srandom CASCADE', ] @@ -56,27 +56,27 @@ def test_make_external_table(): assert table_info == TableInfo( catalog_name='hive_metastore', schema_name='dummy_srandom', - name='ucx_trandom', + name='dummy_trandom', table_type=TableType.EXTERNAL, data_source_format=DataSourceFormat.JSON, - full_name='hive_metastore.dummy_srandom.ucx_trandom', - storage_location='dbfs:/tmp/ucx_test_RANDOM', + full_name='hive_metastore.dummy_srandom.dummy_trandom', + storage_location='dbfs:/tmp/dummy_trandom', properties={'RemoveAfter': '2024091313'}, ) ctx['log_workspace_link'].assert_called_with( - 'hive_metastore.dummy_srandom.ucx_trandom schema', - 'explore/data/hive_metastore/dummy_srandom/ucx_trandom', + 'hive_metastore.dummy_srandom.dummy_trandom schema', + 'explore/data/hive_metastore/dummy_srandom/dummy_trandom', ) assert ctx['sql_backend'].queries == [ 'CREATE SCHEMA hive_metastore.dummy_srandom WITH DBPROPERTIES (RemoveAfter=2024091313)', - 'CREATE TABLE hive_metastore.dummy_srandom.ucx_trandom USING json location ' - "'dbfs:/tmp/ucx_test_RANDOM' as SELECT CAST(calories_burnt AS INT) AS `id`, " + 'CREATE TABLE hive_metastore.dummy_srandom.dummy_trandom USING json location ' + "'dbfs:/tmp/dummy_trandom' as SELECT CAST(calories_burnt AS INT) AS `id`, " 'CAST(device_id AS STRING) AS `value` FROM ' 'JSON.`dbfs:/databricks-datasets/iot-stream/data-device`', - "ALTER TABLE hive_metastore.dummy_srandom.ucx_trandom SET TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", - 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.ucx_trandom', + "ALTER TABLE hive_metastore.dummy_srandom.dummy_trandom SET TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", + 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.dummy_trandom', 'DROP SCHEMA IF EXISTS hive_metastore.dummy_srandom CASCADE', ] @@ -87,18 +87,18 @@ def test_make_table_custom_schema(): assert table_info == TableInfo( catalog_name='hive_metastore', schema_name='dummy_srandom', - name='ucx_trandom', + name='dummy_trandom', table_type=TableType.MANAGED, data_source_format=DataSourceFormat.DELTA, - full_name='hive_metastore.dummy_srandom.ucx_trandom', - storage_location='dbfs:/user/hive/warehouse/dummy_srandom/ucx_trandom', + full_name='hive_metastore.dummy_srandom.dummy_trandom', + storage_location='dbfs:/user/hive/warehouse/dummy_srandom/dummy_trandom', properties={'RemoveAfter': '2024091313'}, ) assert ctx['sql_backend'].queries == [ 'CREATE SCHEMA hive_metastore.dummy_srandom WITH DBPROPERTIES (RemoveAfter=2024091313)', - "CREATE TABLE hive_metastore.dummy_srandom.ucx_trandom (`a` INT, `b` STRING) TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", - 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.ucx_trandom', + "CREATE TABLE hive_metastore.dummy_srandom.dummy_trandom (`a` INT, `b` STRING) TBLPROPERTIES ( 'RemoveAfter' = '2024091313' )", + 'DROP TABLE IF EXISTS hive_metastore.dummy_srandom.dummy_trandom', 'DROP SCHEMA IF EXISTS hive_metastore.dummy_srandom CASCADE', ] @@ -120,15 +120,15 @@ def test_make_udf(): assert fn_info == FunctionInfo( catalog_name='hive_metastore', schema_name='dummy_srandom', - name='ucx_trandom', - full_name='hive_metastore.dummy_srandom.ucx_trandom', + name='dummy_frandom', + full_name='hive_metastore.dummy_srandom.dummy_frandom', ) assert ctx['sql_backend'].queries == [ 'CREATE SCHEMA hive_metastore.dummy_srandom WITH DBPROPERTIES (RemoveAfter=2024091313)', - 'CREATE FUNCTION hive_metastore.dummy_srandom.ucx_trandom(x INT) RETURNS ' + 'CREATE FUNCTION hive_metastore.dummy_srandom.dummy_frandom(x INT) RETURNS ' 'FLOAT CONTAINS SQL DETERMINISTIC RETURN 0;', - 'DROP FUNCTION IF EXISTS hive_metastore.dummy_srandom.ucx_trandom', + 'DROP FUNCTION IF EXISTS hive_metastore.dummy_srandom.dummy_frandom', 'DROP SCHEMA IF EXISTS hive_metastore.dummy_srandom CASCADE', ]