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.2.4-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
- report_rebind
- report_rebind_all
- create_report_from_reportjson
- get_report_json
- export_report
- clone_report
- 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
- get_lakehouse_details
- export_model_to_onelake
- create_shortcut_onelake
- delete_shortcut
- 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(
datasetName = 'AdventureWorks'
,tableName = 'Internet Sales'
,columnName = 'SalesAmount'
,sourceColumn = 'SalesAmount'
,dataType = 'Int64'
#,formatString = ''
#,displayFolder = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
tableName str
Required; Name of the table in which the column will reside.
columnName str
Required; Name of the column.
sourceColumn str
Required; Name of the column in the source system.
dataType str
Required; Data type of the column. Options: 'Int64', 'String', 'Double', 'Decimal', 'DateTime', 'Boolean'.
formatString str
Optional; Format string of the column.
description str
Optional; Description of the column.
displayFolder str
Optional; Display folder of the column.
workspaceName 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(
datasetName = 'AdventureWorks'
,tableName = 'Parameter'
,objects = ["[Sales Amount]", "[Order Qty]", "'Internet Sales'[Color]"]
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
tableName 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].
workspaceName 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(
datasetName = 'AdventureWorks'
,tableName = 'Geography'
,hierarchyName = 'Geography Hierarchy'
,levels = ['Continent', 'Country', 'City']
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
tableName str
Required; Name of the table in which the hierarchy will reside.
hierarchyName str
Required; Name of the hierarchy.
Required; List of columns to be included as levels in the hierarchy.
workspaceName 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(
datasetName = 'AdventureWorks'
,tableName = 'Internet Sales'
,measureName = 'Sales Amount'
,expression = "SUM( 'Internet Sales'[SalesAmount] )"
#,displayFolder = ''
#,formatString = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
tableName str
Required; Name of the table in which the measure will reside.
measureName str
Required; Name of the measure.
expression str
Required; DAX expression for the measure.
displayFolder str
Optional; Display folder for the measure.
formatString str
Optional; Format string for the measure.
workspaceName 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(
datasetName = 'AdventureWorks'
,fromTable = 'Internet Sales'
,fromColumn = 'ProductKey'
,toTable = 'Product'
,toColumn = 'ProductKey'
,fromCardinality = 'Many'
,toCardinality = 'One'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
fromTable str
Required; Name of the table on the 'from' side of the relationship
toTable str
Required; Name of the table on the 'to' side of the relationship
fromColumn str
Required; Name of the column on the 'from' side of the relationship
toColumn str
Required; Name of the column on the 'to' side of the relationship
fromCardinality str
Required; Cardinality on the 'from' side of the relationship. Options: ('Many', 'One', None').
toCardinality str
Required; Cardinality on the 'to' side of the relationship. Options: ('Many', 'One', None').
crossFilteringBehavior str
Optional; Setting for the cross filtering behavior of the relationship. Options: ('Automatic', 'OneDirection', 'BothDirections'). Default value: 'Automatic'.
securityFilteringBehavior str
Optional; Setting for the security filtering behavior of the relationship. Options: ('None', 'OneDirection', 'BothDirections'). Default value: 'OneDirection'.
isActive bool
Optional; Setting for whether the relationship is active or not. Default value: True.
relyOnReferentialIntegrity bool
Optional; Setting for the rely on referential integrity of the relationship. Default value: True.
workspaceName 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(
datasetName = 'AdventureWorks'
,roleName = 'Reader'
,roleDescription = 'This role is for...'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
roleName str
Required; Name of the role.
roleDescription str
Optional; Description of the role.
workspaceName 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(
datasetName = 'AdventureWorks'
,roleName = 'Reader'
,tableName = 'UserGeography'
,filterExpression = "'UserGeography'[UserEmail] = USERPRINCIPALNAME()"
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
roleName str
Required; Name of the role to apply row level security.
tableName str
Required; Name of the table to apply row level security.
filterExpression str
Required; DAX expression for the row low level security.
workspaceName 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(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName 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(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName 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(
reportName = 'MyReport'
,clonedReportName = 'MyNewReport'
#,workspaceName = None
#,targetWorkspace = None
#,targetDatasetName = None
)
reportName str
Required; Name of the report to be cloned.
clonedReportName str
Required; Name of the new report.
workspaceName str
Optional; The workspace where the original report resides.
targetWorkspaceName str
Optional; The workspace where the new report will reside. Defaults to using the workspace in which the original report resides.
targetDatasetName 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(
datasetName = 'AdventureWorks'
,directLakeBehavior = 'DirectLakeOnly'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
directLakeBehavior str
Required; Setting for Direct Lake Behavior. Options: ('Automatic', 'DirectLakeOnly', 'DirectQueryOnly').
workspaceName 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(
datasetName = 'AdventureWorks'
#,compatibilityLevel = 1604
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
compatibilityLevel int
Optional; Setting for the compatibility level of the semantic model. Default value: 1604.
workspaceName 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(
datasetName = 'AdventureWorks'
#,fileName = 'PowerQueryTemplate'
#,workspaceName = ''
)
datasetName str
Required; Name of the import/DirectQuery semantic model.
fileName str
Optional; TName of the Power Query Template (.pqt) file to be created.
workspaceName 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(
reportName = 'MyReport'
,datasetName = 'AdventureWorks'
,reportJson = ''
#,themeJson = ''
#,workspaceName = ''
)
reportName str
Required; Name of the report.
datasetName 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.
workspaceName 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(
datasetName = 'AdventureWorks'
,bimFile = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
Required; The model.bim file to be used to create the semantic model.
workspaceName 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(
tableName = 'DimCalendar'
,sourceLakehouseName = 'Lakehouse1'
,sourceWorkspaceName = 'Workspace1'
,destinationLakehouseName = 'Lakehouse2'
#,destinationWorkspaceName = ''
,shortcutName = 'Calendar'
)
tableName str
Required; The table name for which a shortcut will be created.
sourceLakehouseName str
Required; The lakehouse in which the table resides.
sourceWorkspaceName str
Required; The workspace where the source lakehouse resides.
destinationLakehouseName str
Required; The lakehouse where the shortcut will be created.
destinationWorkspaceName str
Optional; The workspace in which the shortcut will be created. Defaults to the 'sourceWorkspaceName' parameter value.
shortcutName str
Optional; The name of the shortcut 'table' to be created. This defaults to the 'tableName' parameter value.
Deletes a OneLake shortcut.
import fabric_cat_tools as fct
fct.delete_shortcut(
shortcutName = 'DimCalendar'
,lakehouseName = 'Lakehouse1'
,workspaceName = 'Workspace1'
)
shortcutName str
Required; The name of the OneLake shortcut to delete.
lakehouseName str
Optional; The lakehouse in which the shortcut resides.
workspaceName str
Optional; The workspace where the lakehouse resides.
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(
datasetName = 'AdventureWorks'
,workspaceName = ''
#,lakehouseName = ''
#,lakehouseWorkspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
lakehouseName str
Optional; The lakehouse used by the Direct Lake semantic model.
lakehouseWorkspaceName str
Optional; The workspace in which the lakehouse resides.
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(
datasetName = 'AdvWorks'
,addToModel = True
#,workspaceName = ''
#,lakehouseName = ''
#,lakehouseWorkspaceName = ''
)
datasetName str
Required; Name of the semantic model.
addToModel 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.
workspaceName str
Optional; The workspace where the semantic model resides.
lakehouseName str
Optional; The lakehouse used by the Direct Lake semantic model.
lakehouseWorkspaceName str
Optional; The workspace in which the lakehouse resides.
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(
datasetName = 'AdventureWorks'
,workspaceName = None
,destinationLakehouseName = 'Lakehouse2'
,destinationWorkspaceName = 'Workspace2'
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
destinationLakehouseName 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.
destinationWorkspaceName str
Optional; The workspace in which the lakehouse resides.
import fabric_cat_tools as fct
fct.export_report(
reportName = 'AdventureWorks'
,exportFormat = 'PDF'
#,fileName = None
#,bookmarkName = None
#,pageName = None
#,visualName = None
#,workspaceName = None
)
import fabric_cat_tools as fct
fct.export_report(
reportName = 'AdventureWorks'
,exportFormat = 'PDF'
#,fileName = 'Exports\MyReport'
#,bookmarkName = None
#,pageName = 'ReportSection293847182375'
#,visualName = None
#,workspaceName = None
)
reportName str
Required; Name of the semantic model.
exportFormat 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'.
fileName 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.
bookmarkName str
Optional; The name (GUID) of a bookmark within the report.
pageName str
Optional; The name (GUID) of the report page.
visualName str
Optional; The name (GUID) of a visual. If you specify this parameter you must also specify the pageName parameter.
workspaceName str
Optional; The workspace where the report resides.
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
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(
skuSize = ''
)
skuSize str
Required; Sku size of a workspace/capacity
Note
This function is only relevant to semantic models in Direct Lake mode.
import fabric_cat_tools as fct
fct.get_direct_lake_lakehouse(
datasetName = 'AdventureWorks'
#,workspaceName = ''
#,lakehouseName = ''
#,lakehouseWorkspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
lakehouseName str
Optional; Name of the lakehouse used by the semantic model.
lakehouseWorkspaceName 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(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.get_lakehouse_columns(
lakehouseName = 'AdventureWorks'
#,workspaceName = ''
)
lakehouseName str
Optional; The lakehouse name.
workspaceName str
Optional; The workspace where the lakehouse resides.
import fabric_cat_tools as fct
fct.get_lakehouse_details(
lakehouseName = 'MyLakehouse'
#,workspaceName = ''
)
lakehouseName str
Optional; The lakehouse name.
workspaceName str
Optional; The workspace where the lakehouse resides.
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(
lakehouseName = 'MyLakehouse'
#,workspaceName = ''
,extended = True
,countRows = True)
lakehouseName str
Optional; The lakehouse name.
workspaceName 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.
countRows bool
Optional; Adds an additional column showing the row count of each table. Default value: False.
import fabric_cat_tools as fct
fct.get_measure_dependencies(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.get_report_json(
reportName = 'MyReport'
#,workspaceName = None
)
reportName str
Required; Name of the report.
workspaceName str
Optional; The workspace where the report resides.
import fabric_cat_tools as fct
fct.get_semantic_model_bim(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.get_shared_expression(
lakehouseName = ''
#,workspaceName = ''
)
lakehouseName str
Optional; The lakehouse name.
workspaceName str
Optional; The workspace where the lakehouse resides.
import fabric_cat_tools as fct
fct.get_sku_size(
workspaceName = ''
)
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.import_vertipaq_analyzer(
folderPath = '/lakehouse/default/Files/VertipaqAnalyzer'
,fileName = 'Workspace Name-DatasetName.zip'
)
folderPath str
Required; Folder within your lakehouse in which the .zip file containing the vertipaq analyzer info has been saved.
fileName str
Required; File name of the file which contains the vertipaq analyzer info.
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(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.measure_dependency_tree(
datasetName = 'AdventureWorks'
,measureName = 'Sales Amount'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
measureName str
Required; Name of the measure to use for building a dependency tree.
workspaceName str
Optional; The workspace where the semantic model resides.
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(
datasetName = 'AdventureWorks'
,newDatasetName = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the import/DirectQuery semantic model.
newDatasetName str
Required; Name of the Direct Lake semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
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(
datasetName = 'AdventureWorks'
,newDatasetName = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the import/DirectQuery semantic model.
newDatasetName str
Required; Name of the Direct Lake semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
Note
This function is specifically relevant for import/DirectQuery migration to Direct Lake
import fabric_cat_tools as fct
fct.migrate_field_parameters(
datasetName = 'AdventureWorks'
,newDatasetName = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the import/DirectQuery semantic model.
newDatasetName str
Required; Name of the Direct Lake semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
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(
datasetName = 'AdventureWorks'
,newDatasetName = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the import/DirectQuery semantic model.
newDatasetName str
Required; Name of the Direct Lake semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
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(
datasetName = 'AdventureWorks'
,newDatasetName = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the import/DirectQuery semantic model.
newDatasetName str
Required; Name of the Direct Lake semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
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(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.refresh_semantic_model(
datasetName = 'AdventureWorks'
,refreshType = 'full'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
refreshType str
Optional; Type of processing to perform. Options: ('full', 'automatic', 'dataOnly', 'calculate', 'clearValues', 'defragment'). Default value: 'full'.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.remove_column(
datasetName = 'AdventureWorks'
,tableName = ['Internet Sales', 'Geography']
,columnName = ['SalesAmount', 'GeographyKey']
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
Required; Name of the column's table(s).
Required; Name of the column(s).
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.remove_measure(
datasetName = 'AdventureWorks'
,measureName = ['Sales Amount', 'Order Quantity']
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
measureName str or list of str
Required; Name of the measure(s).
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.remove_table(
datasetName = 'AdventureWorks'
,tableName = ['Internet Sales', 'Geography']
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
Required; Name of the table(s).
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.report_rebind(
reportName = ''
,datasetName = ''
#,workspaceName = ''
)
reportName str
Required; Name of the report.
datasetName str
Required; Name of the semantic model to rebind to the report.
workspaceName str
Optional; The workspace where the semantic model and report reside.
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(
datasetName = ''
,newDatasetName = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model currently binded to the reports.
newDatasetName str
Required; Name of the semantic model to rebind to the reports.
workspaceName str
Optional; The workspace where the semantic models and reports reside.
import fabric_cat_tools as fct
fct.resolve_lakehouse_name(
lakehouseId = ''
#,workspaceName = ''
)
lakehouseId UUID
Required; UUID object representing a lakehouse.
workspaceName str
Optional; The workspace where the lakehouse resides.
import fabric_cat_tools as fct
fct.resolve_lakehouse_id(
lakehouseName = 'MyLakehouse'
#,workspaceName = ''
)
lakehouseName str
Required; Name of the lakehouse.
workspaceName str
Optional; The workspace where the lakehouse resides.
import fabric_cat_tools as fct
fct.resolve_dataset_id(
datasetName = 'MyReport'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.resolve_dataset_name(
datasetId = ''
#,workspaceName = ''
)
datasetId UUID
Required; UUID object representing a semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
import fabric_cat_tools as fct
fct.resolve_report_id(
reportName = 'MyReport'
#,workspaceName = ''
)
reportName str
Required; Name of the report.
workspaceName str
Optional; The workspace where the report resides.
import fabric_cat_tools as fct
fct.resolve_report_name(
reportId = ''
#,workspaceName = ''
)
reportId UUID
Required; UUID object representing a report.
workspaceName str
Optional; The workspace where the report resides.
import fabric_cat_tools as fct
fct.run_model_bpa(
datasetName = 'AdventureWorks'
#,workspaceName = ''
,extend = True
)
datasetName str
Required; Name of the semantic model.
rulesDataFrame
Optional; A pandas dataframe including rules to be analyzed.
workspaceName str
Optional; The workspace where the semantic model resides.
extend bool
Optional; Extends the best practice rules to run advanced rules which leverage DMVs.
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(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
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(
datasetName = ''
#,lakehouseName = ''
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
lakehouseName str
Optional; Name of the lakehouse.
workspaceName str
Optional; The workspace where the semantic model resides.
lakehouseWorkspaceName 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.update_direct_lake_partition_entity(
datasetName = 'AdventureWorks'
,tableName = 'Internet Sales'
,entityName = 'FACT_InternetSales'
#,workspaceName = ''
#,lakehouseName = ''
#,lakehouseWorkspaceName = ''
)
datasetName str
Required; Name of the semantic model.
tableName str
Required; Name of the table in the semantic model.
entityName str
Required; Name of the lakehouse table to be mapped to the semantic model table.
workspaceName str
Optional; The workspace where the semantic model resides.
lakehouseName str
Optional; Name of the lakehouse.
lakehouseWorkspaceName str
Optional; The workspace where the lakehouse resides.
import fabric_cat_tools as fct
fct.vertipaq_analyzer(
datasetName = 'AdventureWorks'
#,workspaceName = ''
,export = None
)
import fabric_cat_tools as fct
fct.vertipaq_analyzer(
datasetName = 'AdventureWorks'
#,workspaceName = ''
,export = 'zip'
)
import fabric_cat_tools as fct
fct.vertipaq_analyzer(
datasetName = 'AdventureWorks'
#,workspaceName = ''
,export = 'table'
)
datasetName str
Required; Name of the semantic model.
workspaceName 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.
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(
datasetName = 'AdventureWorks'
,perspective = 'WarmCache'
,addDependencies = True
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
perspective str
Required; Name of the perspective which contains objects to be used for warming the cache.
addDependencies bool
Optional; Includes object dependencies in the cache warming process.
workspaceName str
Optional; The workspace where the semantic model resides.
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(
datasetName = 'AdventureWorks'
#,workspaceName = ''
)
datasetName str
Required; Name of the semantic model.
workspaceName str
Optional; The workspace where the semantic model resides.
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.
- 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, create a new Dataflows Gen2, and import the Power Query Template file.
- Manually map each table to its destination (your lakehouse).
- 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.
- Version 0.2.4 (Apr 8, 2024)
- Added create_shortcut_onelake function
- Added export_model_to_onelake function
- Added delete_shortcut function
- Removed 'extend' paramter from the run_model_bpa function
- Fixed bug in run_model_bpa function which duplicated violations on hierarchy objects
- Version 0.2.3 (Apr 8, 2024)
- Added export_report function
- Added clone_report function
- Added get_report_json function
- Version 0.2.2 (Apr 4, 2024)
- Fixed bug regarding how Field Parameters are created (add_field_parameter, migrate_field_parameters)
- Added escape clause for get_shared_expression if the SQL Endpoint has not yet been provisioned
- Added functionality to vertipaq_analzyer so that the column cardinality for Direct Lake semantic models is obtained by querying the lakehouse