File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ def run_model_bpa_bulk(
5555 "Workspace B": ["Dataset5", "Dataset 8"],
5656 }
5757 """
58+ from sempy_labs .lakehouse ._schemas import is_schema_enabled
5859
5960 if not lakehouse_attached ():
6061 raise ValueError (
@@ -67,7 +68,9 @@ def run_model_bpa_bulk(
6768 skip_models .extend (["ModelBPA" , "Fabric Capacity Metrics" ])
6869
6970 now = datetime .datetime .now ()
70- output_table = "modelbparesults"
71+ schema_enabled = is_schema_enabled ()
72+ output_table = "dbo/modelbparesults" if schema_enabled else "modelbparesults"
73+
7174 lakeT = get_lakehouse_tables ()
7275 lakeT_filt = lakeT [lakeT ["Table Name" ] == output_table ]
7376 if lakeT_filt .empty :
Original file line number Diff line number Diff line change 3737from ._schemas import (
3838 list_schemas ,
3939 schema_exists ,
40+ is_schema_enabled ,
4041)
4142
4243__all__ = [
6263 "list_lakehouses" ,
6364 "list_schemas" ,
6465 "schema_exists" ,
66+ "is_schema_enabled" ,
6567]
Original file line number Diff line number Diff line change 1313import sempy_labs ._icons as icons
1414
1515
16+ @log
17+ def is_schema_enabled (
18+ lakehouse : Optional [str | UUID ] = None , workspace : Optional [str | UUID ] = None
19+ ) -> bool :
20+ """
21+ Indicates whether a lakehouse has schemas enabled.
22+
23+ Parameters
24+ ----------
25+ lakehouse : str | uuid.UUID, default=None
26+ The Fabric lakehouse name or ID.
27+ Defaults to None which resolves to the lakehouse attached to the notebook.
28+ workspace : str | uuid.UUID, default=None
29+ The Fabric workspace name or ID used by the lakehouse.
30+ Defaults to None which resolves to the workspace of the attached lakehouse
31+ or if no lakehouse attached, resolves to the workspace of the notebook.
32+
33+ Returns
34+ -------
35+ bool
36+ Indicates whether the lakehouse has schemas enabled.
37+ """
38+ workspace_id = resolve_workspace_id (workspace )
39+ (item_name , item_id ) = resolve_lakehouse_name_and_id (lakehouse , workspace )
40+ response = _base_api (f"/v1/workspaces/{ workspace_id } /lakehouses/{ item_id } " )
41+ default_schema = response .json ().get ("properties" , {}).get ("defaultSchema" , None )
42+ if default_schema :
43+ return True
44+ else :
45+ return False
46+
47+
1648@log
1749def list_schemas (
1850 lakehouse : Optional [str | UUID ] = None , workspace : Optional [str | UUID ] = None
You can’t perform that action at this time.
0 commit comments