This is a python library intended to be used in Microsoft Fabric notebooks. This library was originally intended to contain functions used for migrating semantic models to Direct Lake mode. However, it quickly became apparent that functions within such a library could support many other useful activities in the realm of semantic models, reports, lakehouses and really anything Fabric-related. As such, this library contains a variety of functions ranging from running Vertipaq Analyzer or the Best Practice Analyzer against a semantic model to seeing if any lakehouse tables hit Direct Lake guardrails and more.
Instructions for migrating import/DirectQuery semantic models to Direct Lake mode can be found here.
If you encounter any issues, please raise a bug.
If you have ideas for new features/functions, please request a feature.
%pip install "https://raw.githubusercontent.com/m-kovalsky/fabric_cat_tools/main/fabric_cat_tools-0.3.3-py3-none-any.whl"
import fabric_cat_tools as fct
Load fabric_cat_tools into a custom Fabric environment
An even better way to ensure the fabric_cat_tools library is available in your workspace/notebooks is to load it as a library in a custom Fabric environment. If you do this, you will not have to run the above '%pip install' code every time in your notebook. Please follow the steps below.
- Navigate to your Fabric workspace
- Click 'New' -> More options
- Within 'Data Science', click 'Environment'
- Name your environment, click 'Create'
- Download the latest fabric_cat_tools library
- Within 'Custom Libraries', click 'upload'
- Upload the .whl file which was downloaded in step 1
- Click 'Save' at the top right of the screen
- Click 'Publish' at the top right of the screen
- Click 'Publish All'
Update your notebook to use the new environment (must wait for the environment to finish publishing)
- Navigate to your Notebook
- Select your newly created environment within the 'Environment' drop down in the navigation bar at the top of the notebook
- clear_cache
- create_semantic_model_from_bim
- get_semantic_model_bim
- get_measure_dependencies
- measure_dependency_tree
- refresh_semantic_model
- cancel_dataset_refresh
- run_dax
- report_rebind
- report_rebind_all
- create_report_from_reportjson
- get_report_json
- export_report
- clone_report
- list_dashboards
- launch_report
- generate_embedded_filter
- create_pqt_file
- create_blank_semantic_model
- migrate_field_parameters
- migrate_tables_columns_to_semantic_model
- migrate_calc_tables_to_semantic_model
- migrate_model_objects_to_semantic_model
- migrate_calc_tables_to_lakehouse
- refresh_calc_tables
- show_unsupported_direct_lake_objects
- update_direct_lake_partition_entity
- update_direct_lake_model_lakehouse_connection
- check_fallback_reason
- control_fallback
- direct_lake_schema_compare
- direct_lake_schema_sync
- get_direct_lake_lakehouse
- get_directlake_guardrails_for_sku
- get_direct_lake_guardrails
- get_shared_expression
- get_direct_lake_sql_endpoint
- get_sku_size
- list_direct_lake_model_calc_tables
- warm_direct_lake_cache_perspective
- warm_direct_lake_cache_isresident
- get_lakehouse_tables
- get_lakehouse_columns
- list_lakehouses
- export_model_to_onelake
- create_shortcut_onelake
- delete_shortcut
- list_shortcuts
- optimize_lakehouse_tables
- create_warehouse
- update_item
- add_data_column
- add_field_parameter
- add_hierarchy
- add_measure
- add_relationship
- add_rls
- add_role
- remove_column
- remove_measure
- remove_table
- resolve_dataset_id
- resolve_dataset_name
- resolve_lakehouse_id
- resolve_lakehouse_name
- resolve_report_id
- resolve_report_name
import fabric_cat_tools as fct
fct.add_data_column(
dataset = 'AdventureWorks'
,table_name = 'Internet Sales'
,column_name = 'SalesAmount'
,source_column = 'SalesAmount'
,data_type = 'Int64'
#,format_string = ''
#,display_folder = ''
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
table_name str
Required; Name of the table in which the column will reside.
column_name str
Required; Name of the column.
source_column str
Required; Name of the column in the source system.
data_type str
Required; Data type of the column. Options: 'Int64', 'String', 'Double', 'Decimal', 'DateTime', 'Boolean'.
format_string str
Optional; Format string of the column.
description str
Optional; Description of the column.
display_folder str
Optional; Display folder of the column.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
Adds a field parameter to a semantic model.
import fabric_cat_tools as fct
fct.add_field_parameter(
dataset = 'AdventureWorks'
,table_name = 'Parameter'
,objects = ["[Sales Amount]", "[Order Qty]", "'Internet Sales'[Color]"]
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
table_name str
Required; Name of the field parameter table.
Required; List of columns/measures to be included in the field parameter. Columns are fully qualified 'TableName'[ColumnName] and measures are in square brackets [MeasureName].
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.add_hierarchy(
dataset = 'AdventureWorks'
,table_name = 'Geography'
,hierarchy_name = 'Geography Hierarchy'
,levels = ['Continent', 'Country', 'City']
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
table_name str
Required; Name of the table in which the hierarchy will reside.
hierarchy_name str
Required; Name of the hierarchy.
Required; List of columns to be included as levels in the hierarchy.
workspace_name str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.add_measure(
dataset = 'AdventureWorks'
,table_name = 'Internet Sales'
,measure_name = 'Sales Amount'
,expression = "SUM( 'Internet Sales'[SalesAmount] )"
#,display_folder = ''
#,format_string = ''
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
table_name str
Required; Name of the table in which the measure will reside.
measure_name str
Required; Name of the measure.
expression str
Required; DAX expression for the measure.
display_folder str
Optional; Display folder for the measure.
format_string str
Optional; Format string for the measure.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.add_relationship(
dataset = 'AdventureWorks'
,from_table = 'Internet Sales'
,from_column = 'ProductKey'
,to_table = 'Product'
,to_column = 'ProductKey'
,from_cardinality = 'Many'
,to_cardinality = 'One'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
from_table str
Required; Name of the table on the 'from' side of the relationship
to_table str
Required; Name of the table on the 'to' side of the relationship
from_column str
Required; Name of the column on the 'from' side of the relationship
to_column str
Required; Name of the column on the 'to' side of the relationship
from_cardinality str
Required; Cardinality on the 'from' side of the relationship. Options: ('Many', 'One', None').
to_cardinality str
Required; Cardinality on the 'to' side of the relationship. Options: ('Many', 'One', None').
cross_filtering_behavior str
Optional; Setting for the cross filtering behavior of the relationship. Options: ('Automatic', 'OneDirection', 'BothDirections'). Default value: 'Automatic'.
security_filtering_behavior str
Optional; Setting for the security filtering behavior of the relationship. Options: ('None', 'OneDirection', 'BothDirections'). Default value: 'OneDirection'.
is_active bool
Optional; Setting for whether the relationship is active or not. Default value: True.
rely_on_referential_integrity bool
Optional; Setting for the rely on referential integrity of the relationship. Default value: True.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.add_role(
dataset = 'AdventureWorks'
,role_name = 'Reader'
,role_description = 'This role is for...'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
role_name str
Required; Name of the role.
role_description str
Optional; Description of the role.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.add_rls(
dataset = 'AdventureWorks'
,role_name = 'Reader'
,table_name = 'UserGeography'
,filter_expression = "'UserGeography'[UserEmail] = USERPRINCIPALNAME()"
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
role_name str
Required; Name of the role to apply row level security.
table_name str
Required; Name of the table to apply row level security.
filter_expression str
Required; DAX expression for the row low level security.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
Cancels the refresh of a semantic model which was executed via the Enhanced Refresh API.
import fabric_cat_tools as fct
fct.cancel_dataset_refresh(
dataset = 'MyReport'
#,request_id = None
#,workspace = None
)
dataset str
Required; Name of the semantic model.
request_id str
Optional; The request id of a semantic model refresh. Defaults to finding the latest active refresh of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.check_fallback_reason(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
Pandas dataframe showing the tables in the semantic model and their fallback reason.
import fabric_cat_tools as fct
fct.clear_cache(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.clone_report(
report = 'MyReport'
,cloned_report = 'MyNewReport'
#,workspace = None
#,target_workspace = None
#,target_dataset = None
)
report str
Required; Name of the report to be cloned.
cloned_report str
Required; Name of the new report.
workspace str
Optional; The workspace where the original report resides.
target_workspace str
Optional; The workspace where the new report will reside. Defaults to using the workspace in which the original report resides.
target_dataset str
Optional; The semantic model from which the new report will be connected. Defaults to using the semantic model used by the original report.
A printout stating the success/failure of the operation.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.control_fallback(
dataset = 'AdventureWorks'
,direct_lake_behavior = 'DirectLakeOnly'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
direct_lake_behavior str
Required; Setting for Direct Lake Behavior. Options: ('Automatic', 'DirectLakeOnly', 'DirectQueryOnly').
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.create_blank_semantic_model(
dataset = 'AdventureWorks'
#,workspace = None
)
dataset str
Required; Name of the semantic model.
compatibility_level int
Optional; Setting for the compatibility level of the semantic model. Default value: 1605.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
Dynamically generates a Power Query Template file based on the semantic model. The .pqt file is saved within the Files section of your lakehouse.
import fabric_cat_tools as fct
fct.create_pqt_file(
dataset = 'AdventureWorks'
#,file_name = 'PowerQueryTemplate'
#,workspace = ''
)
dataset str
Required; Name of the import/DirectQuery semantic model.
file_name str
Optional; TName of the Power Query Template (.pqt) file to be created.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.create_report_from_reportjson(
report = 'MyReport'
,dataset = 'AdventureWorks'
,report_json = ''
#,theme_json = ''
#,workspace = ''
)
report str
Required; Name of the report.
dataset str
Required; Name of the semantic model to connect to the report.
Required; The report.json file to be used to create the report.
Optional; The theme.json file to be used for the theme of the report.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.create_semantic_model_from_bim(
dataset = 'AdventureWorks'
,bim_file = ''
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
Required; The model.bim file to be used to create the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
Creates a shortcut to a delta table in OneLake.
import fabric_cat_tools as fct
fct.create_shortcut_onelake(
table_name = 'DimCalendar'
,source_lakehouse = 'Lakehouse1'
,source_workspace = 'Workspace1'
,destination_lakehouse = 'Lakehouse2'
#,destination_workspace = ''
,shortcut_name = 'Calendar'
)
table_name str
Required; The table name for which a shortcut will be created.
source_lakehouse str
Required; The lakehouse in which the table resides.
sourceWorkspace str
Required; The workspace where the source lakehouse resides.
destination_lakehouse str
Required; The lakehouse where the shortcut will be created.
destination_workspace str
Optional; The workspace in which the shortcut will be created. Defaults to the 'sourceWorkspaceName' parameter value.
shortcut_name str
Optional; The name of the shortcut 'table' to be created. This defaults to the 'tableName' parameter value.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.create_warehouse(
warehouse = 'MyWarehouse'
,workspace = None
)
warehouse str
Required; Name of the warehouse.
description str
Optional; Description of the warehouse.
workspace str
Optional; The workspace where the warehouse will reside.
A printout stating the success/failure of the operation.
Deletes a OneLake shortcut.
import fabric_cat_tools as fct
fct.delete_shortcut(
shortcut_name = 'DimCalendar'
,lakehouse = 'Lakehouse1'
,workspace = 'Workspace1'
)
shortcut_name str
Required; The name of the OneLake shortcut to delete.
lakehouse str
Optional; The lakehouse in which the shortcut resides.
workspace str
Optional; The workspace where the lakehouse resides.
A printout stating the success/failure of the operation.
Checks that all the tables in a Direct Lake semantic model map to tables in their corresponding lakehouse and that the columns in each table exist.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.direct_lake_schema_compare(
dataset = 'AdventureWorks'
,workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
lakehouse str
Optional; The lakehouse used by the Direct Lake semantic model.
lakehouse_workspace str
Optional; The workspace in which the lakehouse resides.
Shows tables/columns which exist in the semantic model but do not exist in the corresponding lakehouse.
Shows/adds columns which exist in the lakehouse but do not exist in the semantic model (only for tables in the semantic model).
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.direct_lake_schema_sync(
dataset = 'AdvWorks'
,add_to_model = True
#,workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
dataset str
Required; Name of the semantic model.
add_to_model bool
Optional; Adds columns which exist in the lakehouse but do not exist in the semantic model. No new tables are added. Default value: False.
workspace str
Optional; The workspace where the semantic model resides.
lakehouse str
Optional; The lakehouse used by the Direct Lake semantic model.
lakehouse_workspace str
Optional; The workspace in which the lakehouse resides.
A list of columns which exist in the lakehouse but not in the Direct Lake semantic model. If 'add_to_model' is set to True, a printout stating the success/failure of the operation is returned.
Exports a semantic model's tables to delta tables in the lakehouse. Creates shortcuts to the tables if a lakehouse is specified.
Important
This function requires:
XMLA read/write to be enabled on the Fabric capacity.
OneLake Integration feature to be enabled within the semantic model settings.
import fabric_cat_tools as fct
fct.export_model_to_onelake(
dataset = 'AdventureWorks'
,workspace = None
,destination_lakehouse = 'Lakehouse2'
,destination_workspace = 'Workspace2'
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
destination_lakehouse str
Optional; The lakehouse where shortcuts will be created to access the delta tables created by the export. If the lakehouse specified does not exist, one will be created with that name. If no lakehouse is specified, shortcuts will not be created.
destination_workspace str
Optional; The workspace in which the lakehouse resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.export_report(
report = 'AdventureWorks'
,export_format = 'PDF'
#,file_name = None
#,bookmark_name = None
#,page_name = None
#,visual_name = None
#,workspace = None
)
import fabric_cat_tools as fct
fct.export_report(
report = 'AdventureWorks'
,export_format = 'PDF'
#,file_name = 'Exports\MyReport'
#,bookmark_name = None
#,page_name = 'ReportSection293847182375'
#,visual_name = None
#,workspace = None
)
import fabric_cat_tools as fct
fct.export_report(
report = 'AdventureWorks'
,export_format = 'PDF'
#,page_name = 'ReportSection293847182375'
#,report_filter = "'Product Category'[Color] in ('Blue', 'Orange') and 'Calendar'[CalendarYear] <= 2020"
#,workspace = None
)
import fabric_cat_tools as fct
fct.export_report(
report = 'AdventureWorks'
,export_format = 'PDF'
#,page_name = ['ReportSection293847182375', 'ReportSection4818372483347']
#,workspace = None
)
import fabric_cat_tools as fct
fct.export_report(
report = 'AdventureWorks'
,export_format = 'PDF'
#,page_name = ['ReportSection293847182375', 'ReportSection4818372483347']
#,visual_name = ['d84793724739', 'v834729234723847']
#,workspace = None
)
report str
Required; Name of the semantic model.
export_format str
Required; The format in which to export the report. See this link for valid formats: https://learn.microsoft.com/rest/api/power-bi/reports/export-to-file-in-group#fileformat. For image formats, enter the file extension in this parameter, not 'IMAGE'.
file_name str
Optional; The name of the file to be saved within the lakehouse. Do not include the file extension. Defaults ot the reportName parameter value.
bookmark_name str
Optional; The name (GUID) of a bookmark within the report.
Optional; The name (GUID) of the report page.
visual_name str or list of str
Optional; The name (GUID) of a visual. If you specify this parameter you must also specify the page_name parameter.
report_filter str
Optional; A report filter to be applied when exporting the report. Syntax is user-friendly. See above for examples.
workspace str
Optional; The workspace where the report resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.generate_embedded_filter(
filter = "'Product'[Product Category] = 'Bikes' and 'Geography'[Country Code] in (3, 6, 10)"
)
filter str
A string converting the filter into an embedded filter
Shows the guardrails for when Direct Lake semantic models will fallback to Direct Query based on Microsoft's online documentation.
import fabric_cat_tools as fct
fct.get_direct_lake_guardrails()
None
A table showing the Direct Lake guardrails by SKU.
Use the result of the 'get_sku_size' function as an input for this function's skuSize parameter.
import fabric_cat_tools as fct
fct.get_directlake_guardrails_for_sku(
sku_size = ''
)
sku_size str
Required; Sku size of a workspace/capacity
A table showing the Direct Lake guardrails for the given SKU.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.get_direct_lake_lakehouse(
dataset = 'AdventureWorks'
#,workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
lakehouse str
Optional; Name of the lakehouse used by the semantic model.
lakehouse_workspace str
Optional; The workspace where the lakehouse resides.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.get_direct_lake_sql_endpoint(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A string containing the SQL Endpoint ID for a Direct Lake semantic model.
import fabric_cat_tools as fct
fct.get_lakehouse_columns(
lakehouse = 'AdventureWorks'
#,workspace = ''
)
lakehouse str
Optional; The lakehouse name.
workspace str
Optional; The workspace where the lakehouse resides.
A pandas dataframe showing the tables/columns within a lakehouse and their properties.
Shows the tables of a lakehouse and their respective properties. Option to include additional properties relevant to Direct Lake guardrails.
import fabric_cat_tools as fct
fct.get_lakehouse_tables(
lakehouse = 'MyLakehouse'
#,workspace = ''
,extended = True
,count_rows = True)
lakehouse str
Optional; The lakehouse name.
workspace str
Optional; The workspace where the lakehouse resides.
extended bool
Optional; Adds the following additional table properties ['Files', 'Row Groups', 'Table Size', 'Parquet File Guardrail', 'Row Group Guardrail', 'Row Count Guardrail']. Also indicates the SKU for the workspace and whether guardrails are hit. Default value: False.
count_rows bool
Optional; Adds an additional column showing the row count of each table. Default value: False.
export bool
Optional; If specified as True, the resulting dataframe will be exported to a delta table in your lakehouse.
A pandas dataframe showing the delta tables within a lakehouse and their properties.
import fabric_cat_tools as fct
fct.get_measure_dependencies(
dataset = 'AdventureWorks'
#,workspace = None
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A pandas dataframe showing all dependencies for all measures in the semantic model.
import fabric_cat_tools as fct
fct.get_object_level_security(
dataset = 'AdventureWorks'
,workspace = '')
dataset str
Optional; The semantic model name.
workspace str
Optional; The workspace where the semantic model resides.
A pandas dataframe showing the columns used in object level security within a semantic model.
import fabric_cat_tools as fct
fct.get_report_json(
report = 'MyReport'
#,workspace = None
)
import fabric_cat_tools as fct
fct.get_report_json(
report = 'MyReport'
#,workspace = None
,save_to_file_name = 'MyFileName'
)
report str
Required; Name of the report.
workspace str
Optional; The workspace where the report resides.
save_to_file_name str
Optional; Specifying this parameter will save the report.json file to your lakehouse with the file name of this parameter.
The report.json file for a given Power BI report.
import fabric_cat_tools as fct
fct.get_semantic_model_bim(
dataset = 'AdventureWorks'
#,workspace = None
)
import fabric_cat_tools as fct
fct.get_semantic_model_bim(
dataset = 'AdventureWorks'
#,workspace = None
,save_to_file_name = 'MyFileName'
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
save_to_file_name str
Optional; Specifying this parameter will save the model.bim file to your lakehouse with the file name of this parameter.
The model.bim file for a given semantic model.
import fabric_cat_tools as fct
fct.get_shared_expression(
lakehouse = ''
#,workspace = ''
)
lakehouse str
Optional; The lakehouse name.
workspace str
Optional; The workspace where the lakehouse resides.
A string showing the expression which can be used to connect a Direct Lake semantic model to its SQL Endpoint.
import fabric_cat_tools as fct
fct.get_sku_size(
workspace = ''
)
workspace str
Optional; The workspace where the semantic model resides.
A string containing the SKU size for a workspace.
import fabric_cat_tools as fct
fct.import_vertipaq_analyzer(
folder_path = '/lakehouse/default/Files/VertipaqAnalyzer'
,file_name = 'Workspace Name-DatasetName.zip'
)
folder_path str
Required; Folder within your lakehouse in which the .zip file containing the vertipaq analyzer info has been saved.
file_name str
Required; File name of the file which contains the vertipaq analyzer info.
import fabric_cat_tools as fct
fct.launch_report(
report = 'MyReport'
#,workspace = None
)
report str
Required; The name of the report.
workspace str
Optional; The name of the workspace in which the report resides.
import fabric_cat_tools as fct
fct.list_dashboards(
#workspace = ''
)
workspace str
Optional; The workspace name.
A pandas dataframe showing the dashboards which exist in the workspace.
import fabric_cat_tools as fct
fct.list_dataflow_storage_accounts()
None
A pandas dataframe showing the accessible dataflow storage accounts.
Shows the calculated tables and their respective DAX expression for a Direct Lake model (which has been migrated from import/DirectQuery.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.list_direct_lake_model_calc_tables(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A pandas dataframe showing the calculated tables which were migrated to Direct Lake and whose DAX expressions are stored as model annotations.
import fabric_cat_tools as fct
fct.list_lakehouses(
workspace = None
)
workspaceName str
Optional; The workspace where the lakehouse resides.
A pandas dataframe showing the properties of a all lakehouses in a workspace.
import fabric_cat_tools as fct
fct.list_shortcuts(
lakehouse = 'MyLakehouse'
#,workspace = ''
)
lakehouse str
Optional; Name of the lakehouse.
workspace str
Optional; The workspace where the lakehouse resides.
A pandas dataframe showing the shortcuts which exist in a given lakehouse and their properties.
import fabric_cat_tools as fct
fct.measure_dependency_tree(
dataset = 'AdventureWorks'
,measure_name = 'Sales Amount'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
measure_name str
Required; Name of the measure to use for building a dependency tree.
workspace str
Optional; The workspace where the semantic model resides.
A tree view showing the dependencies for a given measure within the semantic model.
Creates delta tables in your lakehouse based on the DAX expression of a calculated table in an import/DirectQuery semantic model. The DAX expression encapsulating the calculated table logic is stored in the new Direct Lake semantic model as model annotations.
Note
This function is specifically relevant for import/DirectQuery migration to Direct Lake
import fabric_cat_tools as fct
fct.migrate_calc_tables_to_lakehouse(
dataset = 'AdventureWorks'
,new_dataset = 'AdventureWorksDL'
#,workspace = ''
#,new_dataset_workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
dataset str
Required; Name of the import/DirectQuery semantic model.
new_dataset str
Required; Name of the Direct Lake semantic model.
workspace str
Optional; The workspace where the semantic model resides.
new_dataset_workspace str
Optional; The workspace to be used by the Direct Lake semantic model.
lakehouse str
Optional; The lakehouse to be used by the Direct Lake semantic model.
lakehouse_workspace str
Optional; The workspace where the lakehouse resides.
A printout stating the success/failure of the operation.
Creates new tables in the Direct Lake semantic model based on the lakehouse tables created using the 'migrate_calc_tables_to_lakehouse' function.
Note
This function is specifically relevant for import/DirectQuery migration to Direct Lake
import fabric_cat_tools as fct
fct.migrate_calc_tables_to_semantic_model(
dataset = 'AdventureWorks'
,new_dataset = 'AdventureWorksDL'
#,workspace = ''
#,new_dataset_workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
dataset str
Required; Name of the import/DirectQuery semantic model.
new_dataset str
Required; Name of the Direct Lake semantic model.
workspace str
Optional; The workspace where the semantic model resides.
new_dataset_workspace str
Optional; The workspace to be used by the Direct Lake semantic model.
lakehouse str
Optional; The lakehouse to be used by the Direct Lake semantic model.
lakehouse_workspace str
Optional; The workspace where the lakehouse resides.
A printout stating the success/failure of the operation.
Note
This function is specifically relevant for import/DirectQuery migration to Direct Lake
import fabric_cat_tools as fct
fct.migrate_field_parameters(
dataset = 'AdventureWorks'
,new_dataset = ''
#,workspace = ''
#,new_dataset_workspace = ''
)
dataset str
Required; Name of the import/DirectQuery semantic model.
new_dataset str
Required; Name of the Direct Lake semantic model.
workspace str
Optional; The workspace where the semantic model resides.
new_dataset_workspace str
Optional; The workspace to be used by the Direct Lake semantic model.
A printout stating the success/failure of the operation.
Adds the rest of the model objects (besides tables/columns) and their properties to a Direct Lake semantic model based on an import/DirectQuery semantic model.
Note
This function is specifically relevant for import/DirectQuery migration to Direct Lake
import fabric_cat_tools as fct
fct.migrate_model_objects_to_semantic_model(
dataset = 'AdventureWorks'
,new_dataset = ''
#,workspace = ''
#,new_dataset_workspace = ''
)
dataset str
Required; Name of the import/DirectQuery semantic model.
new_dataset str
Required; Name of the Direct Lake semantic model.
workspace str
Optional; The workspace where the semantic model resides.
new_dataset_workspace str
Optional; The workspace to be used by the Direct Lake semantic model.
A printout stating the success/failure of the operation.
Adds tables/columns to the new Direct Lake semantic model based on an import/DirectQuery semantic model.
Note
This function is specifically relevant for import/DirectQuery migration to Direct Lake
import fabric_cat_tools as fct
fct.migrate_tables_columns_to_semantic_model(
dataset = 'AdventureWorks'
,new_dataset = 'AdventureWorksDL'
#,workspace = ''
#,new_dataset_workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
dataset str
Required; Name of the import/DirectQuery semantic model.
new_dataset str
Required; Name of the Direct Lake semantic model.
workspace str
Optional; The workspace where the semantic model resides.
new_dataset_workspace str
Optional; The workspace to be used by the Direct Lake semantic model.
lakehouse str
Optional; The lakehouse to be used by the Direct Lake semantic model.
lakehouse_workspace str
Optional; The workspace where the lakehouse resides.
A printout stating the success/failure of the operation.
Shows the default Best Practice Rules for the semantic model used by the run_model_bpa function
import fabric_cat_tools as fct
fct.model_bpa_rules()
A pandas dataframe showing the default semantic model best practice rules.
Runs the OPTIMIZE function over the specified lakehouse tables.
import fabric_cat_tools as fct
fct.optimize_lakehouse_tables(
tables = ['Sales', 'Calendar']
#,lakehouse = None
#,workspace = None
)
import fabric_cat_tools as fct
fct.optimize_lakehouse_tables(
tables = None
#,lakehouse = 'MyLakehouse'
#,workspace = 'MyNewWorkspace'
)
Required; Name(s) of the lakehouse delta table(s) to optimize. If 'None' is entered, all of the delta tables in the lakehouse will be queued to be optimized.
lakehouse str
Optional; Name of the lakehouse.
workspace str
Optional; The workspace where the lakehouse resides.
A printout stating the success/failure of the operation.
Recreates the delta tables in the lakehouse based on the DAX expressions stored as model annotations in the Direct Lake semantic model.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.refresh_calc_tables(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.refresh_semantic_model(
dataset = 'AdventureWorks'
,refresh_type = 'full'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
refresh_type str
Optional; Type of processing to perform. Options: ('full', 'automatic', 'dataOnly', 'calculate', 'clearValues', 'defragment'). Default value: 'full'.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.remove_column(
dataset = 'AdventureWorks'
,table_name = ['Internet Sales', 'Geography']
,column_name = ['SalesAmount', 'GeographyKey']
#,workspace = None
)
dataset str
Required; Name of the semantic model.
Required; Name of the column's table(s).
column_name str or list of str
Required; Name of the column(s).
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.remove_measure(
dataset = 'AdventureWorks'
,measure_name = ['Sales Amount', 'Order Quantity']
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
measure_name str or list of str
Required; Name of the measure(s).
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.remove_table(
dataset = 'AdventureWorks'
,table_name = ['Internet Sales', 'Geography']
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
Required; Name of the table(s).
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.report_rebind(
report = ''
,dataset = ''
#,report_workspace = ''
#,dataset_workspace = ''
)
report str
Required; Name of the report.
dataset str
Required; Name of the semantic model to rebind to the report.
report_workspace str
Optional; The workspace where the report resides.
dataset_workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
Rebinds all reports in a workspace which are bound to a specific semantic model to a new semantic model.
import fabric_cat_tools as fct
fct.report_rebind_all(
dataset = ''
,new_dataset = ''
#,dataset_workspace = ''
#,new_dataset_workspace = ''
#,report_workspace = ''
)
dataset str
Required; Name of the semantic model currently binded to the reports.
new_dataset str
Required; Name of the semantic model to rebind to the reports.
dataset_workspace str
Optional; The workspace where the original semantic model resides.
new_dataset_workspace str
Optional; The workspace where the new semantic model resides.
report_workspace str
Optional; The workspace where the reports reside.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.resolve_lakehouse_name(
lakehouse_id = ''
#,workspace = ''
)
lakehouse_id UUID
Required; UUID object representing a lakehouse.
workspace str
Optional; The workspace where the lakehouse resides.
A string containing the lakehouse name.
import fabric_cat_tools as fct
fct.resolve_lakehouse_id(
lakehouse = 'MyLakehouse'
#,workspace = ''
)
lakehouse str
Required; Name of the lakehouse.
workspace str
Optional; The workspace where the lakehouse resides.
A string conaining the lakehouse ID.
import fabric_cat_tools as fct
fct.resolve_dataset_id(
dataset = 'MyReport'
#,workspace = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
A string containing the semantic model ID.
import fabric_cat_tools as fct
fct.resolve_dataset_name(
dataset_id = ''
#,workspace = ''
)
dataset_id UUID
Required; UUID object representing a semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A string containing the semantic model name.
import fabric_cat_tools as fct
fct.resolve_report_id(
report = 'MyReport'
#,workspace = ''
)
report str
Required; Name of the report.
workspace str
Optional; The workspace where the report resides.
A string containing the report ID.
import fabric_cat_tools as fct
fct.resolve_report_name(
report_id = ''
#,workspace = ''
)
report_id UUID
Required; UUID object representing a report.
workspace str
Optional; The workspace where the report resides.
A string containing the report name.
import fabric_cat_tools as fct
fct.run_dax(
dataset = 'AdventureWorks'
,dax_query = 'Internet Sales'
,user_name = 'FACT_InternetSales'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
dax_query str
Required; The DAX query to be executed.
user_name str
Optional; The workspace where the semantic model resides.
workspace str
Optional; The workspace where the semantic model resides.
A pandas dataframe with the results of the DAX query.
import fabric_cat_tools as fct
fct.run_model_bpa(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
rules_dataframe
Optional; A pandas dataframe including rules to be analyzed.
workspace str
Optional; The workspace where the semantic model resides.
return_dataframe bool
Optional; Returns a pandas dataframe instead of the visualization.
export bool
Optional; Exports the results to a delta table in the lakehouse.
A visualization showing objects which violate each Best Practice Rule by rule category.
Returns a list of a semantic model's objects which are not supported by Direct Lake based on official documentation.
import fabric_cat_tools as fct
fct.show_unsupported_direct_lake_objects(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A list of objects (tables/columns/relationships) within the semantic model which are currently not supported by Direct Lake mode.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.update_direct_lake_model_lakehouse_connection(
dataset = ''
#,lakehouse = ''
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
lakehouse str
Optional; Name of the lakehouse.
workspace str
Optional; The workspace where the semantic model resides.
lakehouse_workspace str
Optional; The workspace where the lakehouse resides.
A printout stating the success/failure of the operation.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.update_direct_lake_partition_entity(
dataset = 'AdventureWorks'
,table_name = 'Internet Sales'
,entity_name = 'FACT_InternetSales'
#,workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
import fabric_cat_tools as fct
fct.update_direct_lake_partition_entity(
dataset = 'AdventureWorks'
,table_name = ['Internet Sales', 'Geography']
,entity_name = ['FACT_InternetSales', 'DimGeography']
#,workspace = ''
#,lakehouse = ''
#,lakehouse_workspace = ''
)
dataset str
Required; Name of the semantic model.
Required; Name of the table in the semantic model.
entity_name str or list of str
Required; Name of the lakehouse table to be mapped to the semantic model table.
workspace str
Optional; The workspace where the semantic model resides.
lakehouse str
Optional; Name of the lakehouse.
lakehouse_workspace str
Optional; The workspace where the lakehouse resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.update_item(
item_type = 'Lakehouse'
,current_name = 'MyLakehouse'
,new_name = 'MyNewLakehouse'
#,description = 'This is my new lakehouse'
#,workspace = None
)
item_type str
Required; Type of item to update. Valid options: 'DataPipeline', 'Eventstream', 'KQLDatabase', 'KQLQueryset', 'Lakehouse', 'MLExperiment', 'MLModel', 'Notebook', 'Warehouse'.
current_name str
Required; Current name of the item.
new_name str
Required; New name of the item.
description str
Optional; New description of the item.
workspace str
Optional; The workspace where the item resides.
A printout stating the success/failure of the operation.
import fabric_cat_tools as fct
fct.vertipaq_analyzer(
dataset = 'AdventureWorks'
#,workspace = ''
,export = None
)
import fabric_cat_tools as fct
fct.vertipaq_analyzer(
dataset = 'AdventureWorks'
#,workspace = ''
,export = 'zip'
)
import fabric_cat_tools as fct
fct.vertipaq_analyzer(
dataset = 'AdventureWorks'
#,workspace = ''
,export = 'table'
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
export str
Optional; Specifying 'zip' will export the results to a zip file in your lakehouse (which can be imported using the import_vertipaq_analyzer function. Specifying 'table' will export the results to delta tables (appended) in your lakehouse. Default value: None.
lakehouse_workspace str
Optional; The workspace in which the lakehouse used by a Direct Lake semantic model resides.
read_stats_from_data bool
Optional; Setting this parameter to true has the function get Column Cardinality and Missing Rows using DAX (Direct Lake semantic models achieve this using a Spark query to the lakehouse).
A visualization of the Vertipaq Analyzer statistics.
Warms the cache of a Direct Lake semantic model by running a simple DAX query against the columns in a perspective
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.warm_direct_lake_cache_perspective(
dataset = 'AdventureWorks'
,perspective = 'WarmCache'
,add_dependencies = True
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
perspective str
Required; Name of the perspective which contains objects to be used for warming the cache.
add_dependencies bool
Optional; Includes object dependencies in the cache warming process.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
Performs a refresh on the semantic model and puts the columns which were in memory prior to the refresh back into memory.
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.warm_direct_lake_cache_isresident(
dataset = 'AdventureWorks'
#,workspace = ''
)
dataset str
Required; Name of the semantic model.
workspace str
Optional; The workspace where the semantic model resides.
A printout stating the success/failure of the operation.
The following process automates the migration of an import/DirectQuery model to a new Direct Lake model. The first step is specifically applicable to models which use Power Query to perform data transformations. If your model does not use Power Query, you must migrate the base tables used in your semantic model to a Fabric lakehouse.
Check out Nikola Ilic's terrific blog post on this topic!
Check out my blog post on this topic!
- Make sure you enable XMLA Read/Write for your capacity
- Make sure you have a lakehouse in a Fabric workspace
- Enable the following setting: Workspace -> Workspace Settings -> General -> Data model settings -> Users can edit data models in the Power BI service
- Download this notebook. Use version 0.2.1 or higher only.
- Make sure you are in the 'Data Engineering' persona. Click the icon at the bottom left corner of your Workspace screen and select 'Data Engineering'
- In your workspace, select 'New -> Import notebook' and import the notebook from step 1.
- Add your lakehouse to your Fabric notebook
- Follow the instructions within the notebook.
Note
The first 4 steps are only necessary if you have logic in Power Query. Otherwise, you will need to migrate your semantic model source tables to lakehouse tables.
- The first step of the notebook creates a Power Query Template (.pqt) file which eases the migration of Power Query logic to Dataflows Gen2.
- After the .pqt file is created, sync files from your OneLake file explorer
- Navigate to your lakehouse (this is critical!). From your lakehouse, create a new Dataflows Gen2, and import the Power Query Template file. Doing this step from your lakehouse will automatically set the destination for all tables to this lakehouse (instead of having to manually map each one).
- Publish the Dataflow Gen2 and wait for it to finish creating the delta lake tables in your lakehouse.
- Back in the notebook, the next step will create your new Direct Lake semantic model with the name of your choice, taking all the relevant properties from the orignal semantic model and refreshing/framing your new semantic model.
Note
As of version 0.2.1, calculated tables are also migrated to Direct Lake (as data tables with their DAX expression stored as model annotations in the new semantic model). Additionally, Field Parameters are migrated as they were in the original semantic model (as a calculated table).
- Finally, you can easily rebind your all reports which use the import/DQ semantic model to the new Direct Lake semantic model in one click.
- Offload your Power Query logic to Dataflows Gen2 inside of Fabric (where it can be maintained and development can continue).
- Dataflows Gen2 will create delta tables in your Fabric lakehouse. These tables can then be used for your Direct Lake model.
- Create a new semantic model in Direct Lake mode containing all the standard tables and columns, calculation groups, measures, relationships, hierarchies, roles, row level security, perspectives, and translations from your original semantic model.
- Viable calculated tables are migrated to the new semantic model as data tables. Delta tables are dynamically generated in the lakehouse to support the Direct Lake model. The calculated table DAX logic is stored as model annotations in the new semantic model.
- Field parameters are migrated to the new semantic model as they were in the original semantic model (as calculated tables). Any calculated columns used in field parameters are automatically removed in the new semantic model's field parameter(s).
- Non-supported objects are not transferred (i.e. calculated columns, relationships using columns with unsupported data types etc.).
- Reports used by your original semantic model will be rebinded to your new semantic model.