@@ -241,17 +241,15 @@ def remove(table_info: TableInfo):
241241
242242@fixture
243243def make_schema (
244- sql_backend ,
245- make_random ,
246- log_workspace_link ,
247- watchdog_remove_after ,
244+ sql_backend , make_random , log_workspace_link , watchdog_remove_after
248245) -> Generator [Callable [..., SchemaInfo ], None , None ]:
249246 """
250247 Create a schema and return its info. Remove it after the test. Returns instance of `databricks.sdk.service.catalog.SchemaInfo`.
251248
252249 Keyword Arguments:
253250 * `catalog_name` (str): The name of the catalog where the schema will be created. Default is `hive_metastore`.
254251 * `name` (str): The name of the schema. Default is a random string.
252+ * `location` (str): The path to the location if it should be a managed schema.
255253
256254 Usage:
257255 ```python
@@ -263,11 +261,17 @@ def test_catalog_fixture(make_catalog, make_schema, make_table):
263261 ```
264262 """
265263
266- def create (* , catalog_name : str = "hive_metastore" , name : str | None = None ) -> SchemaInfo :
264+ def create (
265+ * , catalog_name : str = "hive_metastore" , name : str | None = None , location : str | None = None
266+ ) -> SchemaInfo :
267267 name = name or f"dummy_s{ make_random (4 )} " .lower ()
268268 full_name = f"{ catalog_name } .{ name } " .lower ()
269- sql_backend .execute (f"CREATE SCHEMA { full_name } WITH DBPROPERTIES (RemoveAfter={ watchdog_remove_after } )" )
270- schema_info = SchemaInfo (catalog_name = catalog_name , name = name , full_name = full_name )
269+ schema_ddl = f"CREATE SCHEMA { full_name } "
270+ if location :
271+ schema_ddl = f"{ schema_ddl } LOCATION '{ location } '"
272+ schema_ddl = f"{ schema_ddl } WITH DBPROPERTIES (RemoveAfter={ watchdog_remove_after } )"
273+ sql_backend .execute (schema_ddl )
274+ schema_info = SchemaInfo (catalog_name = catalog_name , name = name , full_name = full_name , storage_location = location )
271275 path = f'explore/data/{ schema_info .catalog_name } /{ schema_info .name } '
272276 log_workspace_link (f'{ schema_info .full_name } schema' , path )
273277 return schema_info
0 commit comments