semantic-link-labs 0.12.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- semantic_link_labs-0.12.8.dist-info/METADATA +354 -0
- semantic_link_labs-0.12.8.dist-info/RECORD +243 -0
- semantic_link_labs-0.12.8.dist-info/WHEEL +5 -0
- semantic_link_labs-0.12.8.dist-info/licenses/LICENSE +21 -0
- semantic_link_labs-0.12.8.dist-info/top_level.txt +1 -0
- sempy_labs/__init__.py +606 -0
- sempy_labs/_a_lib_info.py +2 -0
- sempy_labs/_ai.py +437 -0
- sempy_labs/_authentication.py +264 -0
- sempy_labs/_bpa_translation/_model/_translations_am-ET.po +869 -0
- sempy_labs/_bpa_translation/_model/_translations_ar-AE.po +908 -0
- sempy_labs/_bpa_translation/_model/_translations_bg-BG.po +968 -0
- sempy_labs/_bpa_translation/_model/_translations_ca-ES.po +963 -0
- sempy_labs/_bpa_translation/_model/_translations_cs-CZ.po +943 -0
- sempy_labs/_bpa_translation/_model/_translations_da-DK.po +945 -0
- sempy_labs/_bpa_translation/_model/_translations_de-DE.po +988 -0
- sempy_labs/_bpa_translation/_model/_translations_el-GR.po +993 -0
- sempy_labs/_bpa_translation/_model/_translations_es-ES.po +971 -0
- sempy_labs/_bpa_translation/_model/_translations_fa-IR.po +933 -0
- sempy_labs/_bpa_translation/_model/_translations_fi-FI.po +942 -0
- sempy_labs/_bpa_translation/_model/_translations_fr-FR.po +994 -0
- sempy_labs/_bpa_translation/_model/_translations_ga-IE.po +967 -0
- sempy_labs/_bpa_translation/_model/_translations_he-IL.po +902 -0
- sempy_labs/_bpa_translation/_model/_translations_hi-IN.po +944 -0
- sempy_labs/_bpa_translation/_model/_translations_hu-HU.po +963 -0
- sempy_labs/_bpa_translation/_model/_translations_id-ID.po +946 -0
- sempy_labs/_bpa_translation/_model/_translations_is-IS.po +939 -0
- sempy_labs/_bpa_translation/_model/_translations_it-IT.po +986 -0
- sempy_labs/_bpa_translation/_model/_translations_ja-JP.po +846 -0
- sempy_labs/_bpa_translation/_model/_translations_ko-KR.po +839 -0
- sempy_labs/_bpa_translation/_model/_translations_mt-MT.po +967 -0
- sempy_labs/_bpa_translation/_model/_translations_nl-NL.po +978 -0
- sempy_labs/_bpa_translation/_model/_translations_pl-PL.po +962 -0
- sempy_labs/_bpa_translation/_model/_translations_pt-BR.po +962 -0
- sempy_labs/_bpa_translation/_model/_translations_pt-PT.po +957 -0
- sempy_labs/_bpa_translation/_model/_translations_ro-RO.po +968 -0
- sempy_labs/_bpa_translation/_model/_translations_ru-RU.po +964 -0
- sempy_labs/_bpa_translation/_model/_translations_sk-SK.po +952 -0
- sempy_labs/_bpa_translation/_model/_translations_sl-SL.po +950 -0
- sempy_labs/_bpa_translation/_model/_translations_sv-SE.po +942 -0
- sempy_labs/_bpa_translation/_model/_translations_ta-IN.po +976 -0
- sempy_labs/_bpa_translation/_model/_translations_te-IN.po +947 -0
- sempy_labs/_bpa_translation/_model/_translations_th-TH.po +924 -0
- sempy_labs/_bpa_translation/_model/_translations_tr-TR.po +953 -0
- sempy_labs/_bpa_translation/_model/_translations_uk-UA.po +961 -0
- sempy_labs/_bpa_translation/_model/_translations_zh-CN.po +804 -0
- sempy_labs/_bpa_translation/_model/_translations_zu-ZA.po +969 -0
- sempy_labs/_capacities.py +1198 -0
- sempy_labs/_capacity_migration.py +660 -0
- sempy_labs/_clear_cache.py +351 -0
- sempy_labs/_connections.py +610 -0
- sempy_labs/_dashboards.py +69 -0
- sempy_labs/_data_access_security.py +98 -0
- sempy_labs/_data_pipelines.py +162 -0
- sempy_labs/_dataflows.py +668 -0
- sempy_labs/_dax.py +501 -0
- sempy_labs/_daxformatter.py +80 -0
- sempy_labs/_delta_analyzer.py +467 -0
- sempy_labs/_delta_analyzer_history.py +301 -0
- sempy_labs/_dictionary_diffs.py +221 -0
- sempy_labs/_documentation.py +147 -0
- sempy_labs/_domains.py +51 -0
- sempy_labs/_eventhouses.py +182 -0
- sempy_labs/_external_data_shares.py +230 -0
- sempy_labs/_gateways.py +521 -0
- sempy_labs/_generate_semantic_model.py +521 -0
- sempy_labs/_get_connection_string.py +84 -0
- sempy_labs/_git.py +543 -0
- sempy_labs/_graphQL.py +90 -0
- sempy_labs/_helper_functions.py +2833 -0
- sempy_labs/_icons.py +149 -0
- sempy_labs/_job_scheduler.py +609 -0
- sempy_labs/_kql_databases.py +149 -0
- sempy_labs/_kql_querysets.py +124 -0
- sempy_labs/_kusto.py +137 -0
- sempy_labs/_labels.py +124 -0
- sempy_labs/_list_functions.py +1720 -0
- sempy_labs/_managed_private_endpoints.py +253 -0
- sempy_labs/_mirrored_databases.py +416 -0
- sempy_labs/_mirrored_warehouses.py +60 -0
- sempy_labs/_ml_experiments.py +113 -0
- sempy_labs/_model_auto_build.py +140 -0
- sempy_labs/_model_bpa.py +557 -0
- sempy_labs/_model_bpa_bulk.py +378 -0
- sempy_labs/_model_bpa_rules.py +859 -0
- sempy_labs/_model_dependencies.py +343 -0
- sempy_labs/_mounted_data_factories.py +123 -0
- sempy_labs/_notebooks.py +441 -0
- sempy_labs/_one_lake_integration.py +151 -0
- sempy_labs/_onelake.py +131 -0
- sempy_labs/_query_scale_out.py +433 -0
- sempy_labs/_refresh_semantic_model.py +435 -0
- sempy_labs/_semantic_models.py +468 -0
- sempy_labs/_spark.py +455 -0
- sempy_labs/_sql.py +241 -0
- sempy_labs/_sql_audit_settings.py +207 -0
- sempy_labs/_sql_endpoints.py +214 -0
- sempy_labs/_tags.py +201 -0
- sempy_labs/_translations.py +43 -0
- sempy_labs/_user_delegation_key.py +44 -0
- sempy_labs/_utils.py +79 -0
- sempy_labs/_vertipaq.py +1021 -0
- sempy_labs/_vpax.py +388 -0
- sempy_labs/_warehouses.py +234 -0
- sempy_labs/_workloads.py +140 -0
- sempy_labs/_workspace_identity.py +72 -0
- sempy_labs/_workspaces.py +595 -0
- sempy_labs/admin/__init__.py +170 -0
- sempy_labs/admin/_activities.py +167 -0
- sempy_labs/admin/_apps.py +145 -0
- sempy_labs/admin/_artifacts.py +65 -0
- sempy_labs/admin/_basic_functions.py +463 -0
- sempy_labs/admin/_capacities.py +508 -0
- sempy_labs/admin/_dataflows.py +45 -0
- sempy_labs/admin/_datasets.py +186 -0
- sempy_labs/admin/_domains.py +522 -0
- sempy_labs/admin/_external_data_share.py +100 -0
- sempy_labs/admin/_git.py +72 -0
- sempy_labs/admin/_items.py +265 -0
- sempy_labs/admin/_labels.py +211 -0
- sempy_labs/admin/_reports.py +241 -0
- sempy_labs/admin/_scanner.py +118 -0
- sempy_labs/admin/_shared.py +82 -0
- sempy_labs/admin/_sharing_links.py +110 -0
- sempy_labs/admin/_tags.py +131 -0
- sempy_labs/admin/_tenant.py +503 -0
- sempy_labs/admin/_tenant_keys.py +89 -0
- sempy_labs/admin/_users.py +140 -0
- sempy_labs/admin/_workspaces.py +236 -0
- sempy_labs/deployment_pipeline/__init__.py +23 -0
- sempy_labs/deployment_pipeline/_items.py +580 -0
- sempy_labs/directlake/__init__.py +57 -0
- sempy_labs/directlake/_autosync.py +58 -0
- sempy_labs/directlake/_directlake_schema_compare.py +120 -0
- sempy_labs/directlake/_directlake_schema_sync.py +161 -0
- sempy_labs/directlake/_dl_helper.py +274 -0
- sempy_labs/directlake/_generate_shared_expression.py +94 -0
- sempy_labs/directlake/_get_directlake_lakehouse.py +62 -0
- sempy_labs/directlake/_get_shared_expression.py +34 -0
- sempy_labs/directlake/_guardrails.py +96 -0
- sempy_labs/directlake/_list_directlake_model_calc_tables.py +70 -0
- sempy_labs/directlake/_show_unsupported_directlake_objects.py +90 -0
- sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +239 -0
- sempy_labs/directlake/_update_directlake_partition_entity.py +259 -0
- sempy_labs/directlake/_warm_cache.py +236 -0
- sempy_labs/dotnet_lib/dotnet.runtime.config.json +10 -0
- sempy_labs/environment/__init__.py +23 -0
- sempy_labs/environment/_items.py +212 -0
- sempy_labs/environment/_pubstage.py +223 -0
- sempy_labs/eventstream/__init__.py +37 -0
- sempy_labs/eventstream/_items.py +263 -0
- sempy_labs/eventstream/_topology.py +652 -0
- sempy_labs/graph/__init__.py +59 -0
- sempy_labs/graph/_groups.py +651 -0
- sempy_labs/graph/_sensitivity_labels.py +120 -0
- sempy_labs/graph/_teams.py +125 -0
- sempy_labs/graph/_user_licenses.py +96 -0
- sempy_labs/graph/_users.py +516 -0
- sempy_labs/graph_model/__init__.py +15 -0
- sempy_labs/graph_model/_background_jobs.py +63 -0
- sempy_labs/graph_model/_items.py +149 -0
- sempy_labs/lakehouse/__init__.py +67 -0
- sempy_labs/lakehouse/_blobs.py +247 -0
- sempy_labs/lakehouse/_get_lakehouse_columns.py +102 -0
- sempy_labs/lakehouse/_get_lakehouse_tables.py +274 -0
- sempy_labs/lakehouse/_helper.py +250 -0
- sempy_labs/lakehouse/_lakehouse.py +351 -0
- sempy_labs/lakehouse/_livy_sessions.py +143 -0
- sempy_labs/lakehouse/_materialized_lake_views.py +157 -0
- sempy_labs/lakehouse/_partitioning.py +165 -0
- sempy_labs/lakehouse/_schemas.py +217 -0
- sempy_labs/lakehouse/_shortcuts.py +440 -0
- sempy_labs/migration/__init__.py +35 -0
- sempy_labs/migration/_create_pqt_file.py +238 -0
- sempy_labs/migration/_direct_lake_to_import.py +105 -0
- sempy_labs/migration/_migrate_calctables_to_lakehouse.py +398 -0
- sempy_labs/migration/_migrate_calctables_to_semantic_model.py +148 -0
- sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +533 -0
- sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +172 -0
- sempy_labs/migration/_migration_validation.py +71 -0
- sempy_labs/migration/_refresh_calc_tables.py +131 -0
- sempy_labs/mirrored_azure_databricks_catalog/__init__.py +15 -0
- sempy_labs/mirrored_azure_databricks_catalog/_discover.py +213 -0
- sempy_labs/mirrored_azure_databricks_catalog/_refresh_catalog_metadata.py +45 -0
- sempy_labs/ml_model/__init__.py +23 -0
- sempy_labs/ml_model/_functions.py +427 -0
- sempy_labs/report/_BPAReportTemplate.json +232 -0
- sempy_labs/report/__init__.py +55 -0
- sempy_labs/report/_bpareporttemplate/.pbi/localSettings.json +9 -0
- sempy_labs/report/_bpareporttemplate/.platform +11 -0
- sempy_labs/report/_bpareporttemplate/StaticResources/SharedResources/BaseThemes/CY24SU06.json +710 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/page.json +11 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/1b08bce3bebabb0a27a8/visual.json +191 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/2f22ddb70c301693c165/visual.json +438 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/3b1182230aa6c600b43a/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/58577ba6380c69891500/visual.json +576 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/a2a8fa5028b3b776c96c/visual.json +207 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/adfd47ef30652707b987/visual.json +506 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/b6a80ee459e716e170b1/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/ce3130a721c020cc3d81/visual.json +513 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/92735ae19b31712208ad/page.json +8 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/92735ae19b31712208ad/visuals/66e60dfb526437cd78d1/visual.json +112 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/page.json +11 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/07deb8bce824e1be37d7/visual.json +513 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0b1c68838818b32ad03b/visual.json +352 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0c171de9d2683d10b930/visual.json +37 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0efa01be0510e40a645e/visual.json +542 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/6bf2f0eb830ab53cc668/visual.json +221 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/88d8141cb8500b60030c/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/a753273590beed656a03/visual.json +576 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/b8fdc82cddd61ac447bc/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/d37dce724a0ccc30044b/page.json +9 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/d37dce724a0ccc30044b/visuals/ce8532a7e25020271077/visual.json +38 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/pages.json +10 -0
- sempy_labs/report/_bpareporttemplate/definition/report.json +176 -0
- sempy_labs/report/_bpareporttemplate/definition/version.json +4 -0
- sempy_labs/report/_bpareporttemplate/definition.pbir +14 -0
- sempy_labs/report/_download_report.py +76 -0
- sempy_labs/report/_export_report.py +257 -0
- sempy_labs/report/_generate_report.py +427 -0
- sempy_labs/report/_paginated.py +76 -0
- sempy_labs/report/_report_bpa.py +354 -0
- sempy_labs/report/_report_bpa_rules.py +115 -0
- sempy_labs/report/_report_functions.py +581 -0
- sempy_labs/report/_report_helper.py +227 -0
- sempy_labs/report/_report_list_functions.py +110 -0
- sempy_labs/report/_report_rebind.py +149 -0
- sempy_labs/report/_reportwrapper.py +3100 -0
- sempy_labs/report/_save_report.py +147 -0
- sempy_labs/snowflake_database/__init__.py +10 -0
- sempy_labs/snowflake_database/_items.py +105 -0
- sempy_labs/sql_database/__init__.py +21 -0
- sempy_labs/sql_database/_items.py +201 -0
- sempy_labs/sql_database/_mirroring.py +79 -0
- sempy_labs/theme/__init__.py +12 -0
- sempy_labs/theme/_org_themes.py +129 -0
- sempy_labs/tom/__init__.py +3 -0
- sempy_labs/tom/_model.py +5977 -0
- sempy_labs/variable_library/__init__.py +19 -0
- sempy_labs/variable_library/_functions.py +403 -0
- sempy_labs/warehouse/__init__.py +28 -0
- sempy_labs/warehouse/_items.py +234 -0
- sempy_labs/warehouse/_restore_points.py +309 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from ._functions import (
|
|
2
|
+
get_variable_library,
|
|
3
|
+
list_variables,
|
|
4
|
+
list_variable_libraries,
|
|
5
|
+
delete_variable_library,
|
|
6
|
+
get_variable_library_definition,
|
|
7
|
+
get_variable_values,
|
|
8
|
+
get_variable_value,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"get_variable_library",
|
|
13
|
+
"list_variables",
|
|
14
|
+
"list_variable_libraries",
|
|
15
|
+
"delete_variable_library",
|
|
16
|
+
"get_variable_library_definition",
|
|
17
|
+
"get_variable_values",
|
|
18
|
+
"get_variable_value",
|
|
19
|
+
]
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
from sempy_labs._helper_functions import (
|
|
2
|
+
resolve_item_id,
|
|
3
|
+
resolve_workspace_id,
|
|
4
|
+
_base_api,
|
|
5
|
+
_create_dataframe,
|
|
6
|
+
_update_dataframe_datatypes,
|
|
7
|
+
delete_item,
|
|
8
|
+
_decode_b64,
|
|
9
|
+
)
|
|
10
|
+
import pandas as pd
|
|
11
|
+
from typing import Any, Optional, List, Union
|
|
12
|
+
from uuid import UUID
|
|
13
|
+
from sempy._utils._log import log
|
|
14
|
+
import json
|
|
15
|
+
import sempy_labs._icons as icons
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@log
|
|
19
|
+
def get_variable_library(
|
|
20
|
+
variable_library: str | UUID, workspace: Optional[str | UUID] = None
|
|
21
|
+
) -> pd.DataFrame:
|
|
22
|
+
"""
|
|
23
|
+
Returns properties of the specified variable library.
|
|
24
|
+
|
|
25
|
+
This is a wrapper function for the following API: `Items - Get Variable Library <https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/get-variable-library>`_.
|
|
26
|
+
|
|
27
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
variable_library : str | uuid.UUID
|
|
32
|
+
Name or ID of the variable library.
|
|
33
|
+
workspace : str | uuid.UUID, default=None
|
|
34
|
+
The Fabric workspace name or ID.
|
|
35
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
36
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
pandas.DataFrame
|
|
41
|
+
A pandas dataframe showing the properties of the variable library.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
columns = {
|
|
45
|
+
"Variable Library Name": "string",
|
|
46
|
+
"Variable Library Id": "string",
|
|
47
|
+
"Description": "string",
|
|
48
|
+
"Active Value Set Name": "string",
|
|
49
|
+
}
|
|
50
|
+
df = _create_dataframe(columns=columns)
|
|
51
|
+
|
|
52
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
53
|
+
variable_library_id = resolve_item_id(
|
|
54
|
+
item=variable_library, type="VariableLibrary", workspace=workspace
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
response = _base_api(
|
|
58
|
+
request=f"/v1/workspaces/{workspace_id}/variableLibraries/{variable_library_id}",
|
|
59
|
+
client="fabric_sp",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
result = response.json()
|
|
63
|
+
prop = result.get("properties", {})
|
|
64
|
+
|
|
65
|
+
if prop:
|
|
66
|
+
df = pd.DataFrame(
|
|
67
|
+
[
|
|
68
|
+
{
|
|
69
|
+
"Variable Library Name": result.get("displayName"),
|
|
70
|
+
"Variable Library Id": result.get("id"),
|
|
71
|
+
"Description": result.get("description"),
|
|
72
|
+
"Active Value Set Name": prop.get("activeValueSetName"),
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
columns=list(columns.keys()),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
_update_dataframe_datatypes(dataframe=df, column_map=columns)
|
|
79
|
+
|
|
80
|
+
return df
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@log
|
|
84
|
+
def list_variable_libraries(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
|
|
85
|
+
"""
|
|
86
|
+
Shows the variable libraries within a workspace.
|
|
87
|
+
|
|
88
|
+
This is a wrapper function for the following API: `Items - List Variable Libraries <https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/list-variable-libraries>`_.
|
|
89
|
+
|
|
90
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
workspace : str | uuid.UUID, default=None
|
|
95
|
+
The Fabric workspace name or ID.
|
|
96
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
97
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
98
|
+
|
|
99
|
+
Returns
|
|
100
|
+
-------
|
|
101
|
+
pandas.DataFrame
|
|
102
|
+
A pandas dataframe showing the variable libraries within a workspace.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
columns = {
|
|
106
|
+
"Variable Library Name": "string",
|
|
107
|
+
"Variable Library Id": "string",
|
|
108
|
+
"Description": "string",
|
|
109
|
+
"Active Value Set Name": "string",
|
|
110
|
+
}
|
|
111
|
+
df = _create_dataframe(columns=columns)
|
|
112
|
+
|
|
113
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
114
|
+
|
|
115
|
+
responses = _base_api(
|
|
116
|
+
request=f"/v1/workspaces/{workspace_id}/VariableLibraries",
|
|
117
|
+
uses_pagination=True,
|
|
118
|
+
client="fabric_sp",
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
rows = []
|
|
122
|
+
for r in responses:
|
|
123
|
+
for v in r.get("value", []):
|
|
124
|
+
prop = v.get("properties", {})
|
|
125
|
+
|
|
126
|
+
rows.append(
|
|
127
|
+
{
|
|
128
|
+
"Variable Library Name": v.get("displayName"),
|
|
129
|
+
"Variable Library Id": v.get("id"),
|
|
130
|
+
"Description": v.get("description"),
|
|
131
|
+
"Active Value Set Name": prop.get("activeValueSetName"),
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if rows:
|
|
136
|
+
df = pd.DataFrame(rows, columns=list(columns.keys()))
|
|
137
|
+
_update_dataframe_datatypes(dataframe=df, column_map=columns)
|
|
138
|
+
|
|
139
|
+
return df
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
@log
|
|
143
|
+
def delete_variable_library(
|
|
144
|
+
variable_library: str | UUID, workspace: Optional[str | UUID] = None
|
|
145
|
+
):
|
|
146
|
+
"""
|
|
147
|
+
Deletes a variable library.
|
|
148
|
+
|
|
149
|
+
This is a wrapper function for the following API: `Items - Delete Variable Library https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/delete-variable-library>`_.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
navariable_libraryme: str | uuid.UUID
|
|
154
|
+
Name or ID of the variable library.
|
|
155
|
+
workspace : str | uuid.UUID, default=None
|
|
156
|
+
The Fabric workspace name or ID.
|
|
157
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
158
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
delete_item(item=variable_library, type="VariableLibrary", workspace=workspace)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@log
|
|
165
|
+
def get_variable_library_definition(
|
|
166
|
+
variable_library: str | UUID,
|
|
167
|
+
workspace: Optional[str | UUID] = None,
|
|
168
|
+
decode: bool = True,
|
|
169
|
+
return_dataframe: bool = False,
|
|
170
|
+
) -> dict | pd.DataFrame:
|
|
171
|
+
"""
|
|
172
|
+
Gets the definition of a variable library.
|
|
173
|
+
|
|
174
|
+
This is a wrapper function for the following API: `Items - Get Variable Library Definition <https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/delete-variable-library>`_.
|
|
175
|
+
|
|
176
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
177
|
+
|
|
178
|
+
Parameters
|
|
179
|
+
----------
|
|
180
|
+
workspace : str | uuid.UUID, default=None
|
|
181
|
+
The Fabric workspace name or ID.
|
|
182
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
183
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
184
|
+
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
dict | pandas.DataFrame
|
|
188
|
+
A dictionary showing the definition or a pandas dataframe showing the definition.
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
192
|
+
variable_library_id = resolve_item_id(
|
|
193
|
+
item=variable_library, type="VariableLibrary", workspace=workspace
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
result = _base_api(
|
|
197
|
+
request=f"/v1/workspaces/{workspace_id}/variableLibraries/{variable_library_id}/getDefinition",
|
|
198
|
+
method="post",
|
|
199
|
+
client="fabric_sp",
|
|
200
|
+
status_codes=None,
|
|
201
|
+
lro_return_json=True,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
if decode:
|
|
205
|
+
definition = {"definition": {"parts": []}}
|
|
206
|
+
|
|
207
|
+
for part in result.get("definition", {}).get("parts", []):
|
|
208
|
+
path = part.get("path")
|
|
209
|
+
payload = _decode_b64(part.get("payload"))
|
|
210
|
+
definition["definition"]["parts"].append({"path": path, "payload": payload})
|
|
211
|
+
else:
|
|
212
|
+
definition = result.copy()
|
|
213
|
+
|
|
214
|
+
if return_dataframe:
|
|
215
|
+
df = pd.DataFrame(definition["definition"]["parts"])
|
|
216
|
+
df.columns = ["Path", "Payload", "Payload Type"]
|
|
217
|
+
return df
|
|
218
|
+
else:
|
|
219
|
+
return definition
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@log
|
|
223
|
+
def list_variables(
|
|
224
|
+
variable_library: str | UUID, workspace: Optional[str | UUID] = None
|
|
225
|
+
) -> pd.DataFrame:
|
|
226
|
+
"""
|
|
227
|
+
Lists the variables in a variable library.
|
|
228
|
+
|
|
229
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
230
|
+
|
|
231
|
+
Parameters
|
|
232
|
+
----------
|
|
233
|
+
variable_library : str | uuid.UUID
|
|
234
|
+
Name or ID of the variable library.
|
|
235
|
+
workspace : str | uuid.UUID, default=None
|
|
236
|
+
The Fabric workspace name or ID.
|
|
237
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
238
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
239
|
+
|
|
240
|
+
Returns
|
|
241
|
+
-------
|
|
242
|
+
pandas.DataFrame
|
|
243
|
+
A pandas dataframe showing the variables within a variable library.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
result = get_variable_library_definition(
|
|
247
|
+
variable_library=variable_library,
|
|
248
|
+
workspace=workspace,
|
|
249
|
+
decode=True,
|
|
250
|
+
return_dataframe=False,
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
columns = {
|
|
254
|
+
"Variable Name": "string",
|
|
255
|
+
"Note": "string",
|
|
256
|
+
"Type": "string",
|
|
257
|
+
"Value": "string",
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
df = _create_dataframe(columns=columns)
|
|
261
|
+
|
|
262
|
+
rows = []
|
|
263
|
+
for part in result.get("definition").get("parts"):
|
|
264
|
+
path = part.get("path")
|
|
265
|
+
payload = json.loads(part.get("payload"))
|
|
266
|
+
if path == "variables.json":
|
|
267
|
+
|
|
268
|
+
for variable in payload.get("variables", []):
|
|
269
|
+
rows.append(
|
|
270
|
+
{
|
|
271
|
+
"Variable Name": variable.get("name"),
|
|
272
|
+
"Note": variable.get("note"),
|
|
273
|
+
"Type": variable.get("type"),
|
|
274
|
+
"Value": variable.get("value"),
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
if rows:
|
|
279
|
+
df = pd.DataFrame(rows, columns=list(columns.keys()))
|
|
280
|
+
|
|
281
|
+
for part in result.get("definition", {}).get("parts", []):
|
|
282
|
+
path = part.get("path")
|
|
283
|
+
if path.startswith("valueSets") and path.endswith(".json"):
|
|
284
|
+
payload = json.loads(part.get("payload"))
|
|
285
|
+
value_set_name = payload.get("name")
|
|
286
|
+
|
|
287
|
+
# Initialize the new column with None (or pd.NA)
|
|
288
|
+
df[value_set_name] = None
|
|
289
|
+
|
|
290
|
+
for override in payload.get("variableOverrides", []):
|
|
291
|
+
variable_name = override.get("name")
|
|
292
|
+
variable_value = override.get("value")
|
|
293
|
+
|
|
294
|
+
# Set the value in the appropriate row and column
|
|
295
|
+
df.loc[df["Variable Name"] == variable_name, value_set_name] = (
|
|
296
|
+
variable_value
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
return df
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@log
|
|
303
|
+
def get_variable_values(
|
|
304
|
+
variable_names: List[str],
|
|
305
|
+
variable_library: Union[str, UUID],
|
|
306
|
+
workspace: Optional[Union[str, UUID]] = None,
|
|
307
|
+
value_set: Optional[str] = None,
|
|
308
|
+
) -> dict:
|
|
309
|
+
"""
|
|
310
|
+
Gets the values of multiple variables from a variable library with a single call to list_variables.
|
|
311
|
+
|
|
312
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
313
|
+
|
|
314
|
+
Parameters
|
|
315
|
+
----------
|
|
316
|
+
variable_names : List[str]
|
|
317
|
+
A list of variable names to retrieve.
|
|
318
|
+
variable_library : str | uuid.UUID
|
|
319
|
+
Name or ID of the variable library.
|
|
320
|
+
workspace : str | uuid.UUID, default=None
|
|
321
|
+
The Fabric workspace name or ID.
|
|
322
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
323
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
324
|
+
value_set : str, default=None
|
|
325
|
+
The name of the value set to use for variable overrides.
|
|
326
|
+
If None, the active value set of the variable library will be used.
|
|
327
|
+
|
|
328
|
+
Returns
|
|
329
|
+
-------
|
|
330
|
+
dict
|
|
331
|
+
Dictionary mapping variable names to their corresponding values.
|
|
332
|
+
"""
|
|
333
|
+
|
|
334
|
+
if isinstance(variable_names, str):
|
|
335
|
+
variable_names = [variable_names]
|
|
336
|
+
|
|
337
|
+
if value_set is None:
|
|
338
|
+
vl_df = get_variable_library(
|
|
339
|
+
variable_library=variable_library, workspace=workspace
|
|
340
|
+
)
|
|
341
|
+
if vl_df.empty:
|
|
342
|
+
raise ValueError(
|
|
343
|
+
f"{icons.red_dot} The variable library '{variable_library}' does not exist within the '{workspace}' workspace."
|
|
344
|
+
)
|
|
345
|
+
value_set = vl_df["Active Value Set Name"].iloc[0]
|
|
346
|
+
|
|
347
|
+
df = list_variables(variable_library=variable_library, workspace=workspace)
|
|
348
|
+
found_variables = df[df["Variable Name"].isin(variable_names)]
|
|
349
|
+
|
|
350
|
+
missing = set(variable_names) - set(found_variables["Variable Name"])
|
|
351
|
+
if missing:
|
|
352
|
+
raise ValueError(
|
|
353
|
+
f"{icons.red_dot} The following variables do not exist in the '{variable_library}' variable library: {', '.join(missing)}"
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
if value_set == "Default value set":
|
|
357
|
+
value_set = "Value"
|
|
358
|
+
if value_set not in df.columns:
|
|
359
|
+
raise ValueError(
|
|
360
|
+
f"{icons.red_dot} The value set '{value_set}' does not exist in the variable library '{variable_library}' within the '{workspace}' workspace."
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
return dict(zip(found_variables["Variable Name"], found_variables[value_set]))
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
@log
|
|
367
|
+
def get_variable_value(
|
|
368
|
+
variable_name: str,
|
|
369
|
+
variable_library: str | UUID,
|
|
370
|
+
workspace: Optional[str | UUID] = None,
|
|
371
|
+
value_set: Optional[str] = None,
|
|
372
|
+
) -> Any:
|
|
373
|
+
"""
|
|
374
|
+
Gets the value of a single variable in a variable library.
|
|
375
|
+
|
|
376
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
377
|
+
|
|
378
|
+
Parameters
|
|
379
|
+
----------
|
|
380
|
+
variable_name : str
|
|
381
|
+
Name of the variable.
|
|
382
|
+
variable_library : str | uuid.UUID
|
|
383
|
+
Name or ID of the variable library.
|
|
384
|
+
workspace : str | uuid.UUID, default=None
|
|
385
|
+
The Fabric workspace name or ID.
|
|
386
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
387
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
388
|
+
value_set : str, default=None
|
|
389
|
+
The name of the value set to use for variable overrides.
|
|
390
|
+
If None, the active value set of the variable library will be used.
|
|
391
|
+
|
|
392
|
+
Returns
|
|
393
|
+
-------
|
|
394
|
+
Any
|
|
395
|
+
The value of the variable.
|
|
396
|
+
"""
|
|
397
|
+
|
|
398
|
+
return get_variable_values(
|
|
399
|
+
variable_names=[variable_name],
|
|
400
|
+
variable_library=variable_library,
|
|
401
|
+
workspace=workspace,
|
|
402
|
+
value_set=value_set,
|
|
403
|
+
)[variable_name]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from ._restore_points import (
|
|
2
|
+
create_restore_point,
|
|
3
|
+
delete_restore_point,
|
|
4
|
+
list_restore_points,
|
|
5
|
+
update_restore_point,
|
|
6
|
+
restore_to_restore_point,
|
|
7
|
+
)
|
|
8
|
+
from ._items import (
|
|
9
|
+
create_warehouse,
|
|
10
|
+
delete_warehouse,
|
|
11
|
+
get_warehouse_tables,
|
|
12
|
+
get_warehouse_columns,
|
|
13
|
+
list_warehouses,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"create_restore_point",
|
|
19
|
+
"delete_restore_point",
|
|
20
|
+
"list_restore_points",
|
|
21
|
+
"update_restore_point",
|
|
22
|
+
"restore_to_restore_point",
|
|
23
|
+
"create_warehouse",
|
|
24
|
+
"delete_warehouse",
|
|
25
|
+
"get_warehouse_tables",
|
|
26
|
+
"get_warehouse_columns",
|
|
27
|
+
"list_warehouses",
|
|
28
|
+
]
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
from sempy_labs._helper_functions import (
|
|
2
|
+
resolve_workspace_name_and_id,
|
|
3
|
+
_base_api,
|
|
4
|
+
_create_dataframe,
|
|
5
|
+
_update_dataframe_datatypes,
|
|
6
|
+
delete_item,
|
|
7
|
+
resolve_workspace_id,
|
|
8
|
+
)
|
|
9
|
+
import pandas as pd
|
|
10
|
+
from typing import Optional
|
|
11
|
+
import sempy_labs._icons as icons
|
|
12
|
+
from uuid import UUID
|
|
13
|
+
from sempy._utils._log import log
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@log
|
|
17
|
+
def create_warehouse(
|
|
18
|
+
warehouse: str,
|
|
19
|
+
description: Optional[str] = None,
|
|
20
|
+
case_insensitive_collation: bool = False,
|
|
21
|
+
workspace: Optional[str | UUID] = None,
|
|
22
|
+
) -> UUID:
|
|
23
|
+
"""
|
|
24
|
+
Creates a Fabric warehouse.
|
|
25
|
+
|
|
26
|
+
This is a wrapper function for the following API: `Items - Create Warehouse <https://learn.microsoft.com/rest/api/fabric/warehouse/items/create-warehouse>`_.
|
|
27
|
+
|
|
28
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
warehouse: str
|
|
33
|
+
Name of the warehouse.
|
|
34
|
+
description : str, default=None
|
|
35
|
+
A description of the warehouse.
|
|
36
|
+
case_insensitive_collation: bool, default=False
|
|
37
|
+
If True, creates the warehouse with case-insensitive collation.
|
|
38
|
+
workspace : str | uuid.UUID, default=None
|
|
39
|
+
The Fabric workspace name or ID.
|
|
40
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
41
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
uuid.UUID
|
|
46
|
+
The ID of the created warehouse.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
50
|
+
|
|
51
|
+
payload = {"displayName": warehouse}
|
|
52
|
+
|
|
53
|
+
if description:
|
|
54
|
+
payload["description"] = description
|
|
55
|
+
if case_insensitive_collation:
|
|
56
|
+
payload.setdefault("creationPayload", {})
|
|
57
|
+
payload["creationPayload"][
|
|
58
|
+
"defaultCollation"
|
|
59
|
+
] = "Latin1_General_100_CI_AS_KS_WS_SC_UTF8"
|
|
60
|
+
|
|
61
|
+
result = _base_api(
|
|
62
|
+
request=f"/v1/workspaces/{workspace_id}/warehouses",
|
|
63
|
+
payload=payload,
|
|
64
|
+
method="post",
|
|
65
|
+
lro_return_json=True,
|
|
66
|
+
status_codes=[201, 202],
|
|
67
|
+
client="fabric_sp",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
print(
|
|
71
|
+
f"{icons.green_dot} The '{warehouse}' warehouse has been created within the '{workspace_name}' workspace."
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
return result.get("id")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@log
|
|
78
|
+
def list_warehouses(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
|
|
79
|
+
"""
|
|
80
|
+
Shows the warehouses within a workspace.
|
|
81
|
+
|
|
82
|
+
This is a wrapper function for the following API: `Items - List Warehouses <https://learn.microsoft.com/rest/api/fabric/warehouse/items/list-warehouses>`_.
|
|
83
|
+
|
|
84
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
85
|
+
|
|
86
|
+
Parameters
|
|
87
|
+
----------
|
|
88
|
+
workspace : str | uuid.UUID, default=None
|
|
89
|
+
The Fabric workspace name or ID.
|
|
90
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
91
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
pandas.DataFrame
|
|
96
|
+
A pandas dataframe showing the warehouses within a workspace.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
columns = {
|
|
100
|
+
"Warehouse Name": "string",
|
|
101
|
+
"Warehouse Id": "string",
|
|
102
|
+
"Description": "string",
|
|
103
|
+
"Connection Info": "string",
|
|
104
|
+
"Created Date": "datetime",
|
|
105
|
+
"Last Updated Time": "datetime",
|
|
106
|
+
}
|
|
107
|
+
df = _create_dataframe(columns=columns)
|
|
108
|
+
|
|
109
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
110
|
+
|
|
111
|
+
responses = _base_api(
|
|
112
|
+
request=f"/v1/workspaces/{workspace_id}/warehouses",
|
|
113
|
+
uses_pagination=True,
|
|
114
|
+
client="fabric_sp",
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
rows = []
|
|
118
|
+
for r in responses:
|
|
119
|
+
for v in r.get("value", []):
|
|
120
|
+
prop = v.get("properties", {})
|
|
121
|
+
|
|
122
|
+
rows.append(
|
|
123
|
+
{
|
|
124
|
+
"Warehouse Name": v.get("displayName"),
|
|
125
|
+
"Warehouse Id": v.get("id"),
|
|
126
|
+
"Description": v.get("description"),
|
|
127
|
+
"Connection Info": prop.get("connectionInfo"),
|
|
128
|
+
"Created Date": prop.get("createdDate"),
|
|
129
|
+
"Last Updated Time": prop.get("lastUpdatedTime"),
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
if rows:
|
|
134
|
+
df = pd.DataFrame(rows, columns=list(columns.keys()))
|
|
135
|
+
_update_dataframe_datatypes(dataframe=df, column_map=columns)
|
|
136
|
+
|
|
137
|
+
return df
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@log
|
|
141
|
+
def delete_warehouse(name: str | UUID, workspace: Optional[str | UUID] = None):
|
|
142
|
+
"""
|
|
143
|
+
Deletes a Fabric warehouse.
|
|
144
|
+
|
|
145
|
+
This is a wrapper function for the following API: `Items - Delete Warehouse <https://learn.microsoft.com/rest/api/fabric/warehouse/items/delete-warehouse>`_.
|
|
146
|
+
|
|
147
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
148
|
+
|
|
149
|
+
Parameters
|
|
150
|
+
----------
|
|
151
|
+
name: str | uuid.UUID
|
|
152
|
+
Name or ID of the warehouse.
|
|
153
|
+
workspace : str | uuid.UUID, default=None
|
|
154
|
+
The Fabric workspace name or ID.
|
|
155
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
156
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
delete_item(item=name, type="Warehouse", workspace=workspace)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@log
|
|
163
|
+
def get_warehouse_tables(
|
|
164
|
+
warehouse: str | UUID, workspace: Optional[str | UUID] = None
|
|
165
|
+
) -> pd.DataFrame:
|
|
166
|
+
"""
|
|
167
|
+
Shows a list of the tables in the Fabric warehouse. This function is based on INFORMATION_SCHEMA.TABLES.
|
|
168
|
+
|
|
169
|
+
Parameters
|
|
170
|
+
----------
|
|
171
|
+
warehouse : str | uuid.UUID
|
|
172
|
+
Name or ID of the Fabric warehouse.
|
|
173
|
+
workspace : str | uuid.UUID, default=None
|
|
174
|
+
The Fabric workspace name or ID.
|
|
175
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
176
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
177
|
+
|
|
178
|
+
Returns
|
|
179
|
+
-------
|
|
180
|
+
pandas.DataFrame
|
|
181
|
+
A pandas dataframe showing a list of the tables in the Fabric warehouse.
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
from sempy_labs._sql import ConnectWarehouse
|
|
185
|
+
|
|
186
|
+
with ConnectWarehouse(warehouse=warehouse, workspace=workspace) as sql:
|
|
187
|
+
df = sql.query(
|
|
188
|
+
"""
|
|
189
|
+
SELECT TABLE_SCHEMA AS [Schema], TABLE_NAME AS [Table Name], TABLE_TYPE AS [Table Type]
|
|
190
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
191
|
+
WHERE TABLE_TYPE = 'BASE TABLE'
|
|
192
|
+
"""
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
return df
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@log
|
|
199
|
+
def get_warehouse_columns(
|
|
200
|
+
warehouse: str | UUID, workspace: Optional[str | UUID] = None
|
|
201
|
+
) -> pd.DataFrame:
|
|
202
|
+
"""
|
|
203
|
+
Shows a list of the columns in each table within the Fabric warehouse. This function is based on INFORMATION_SCHEMA.COLUMNS.
|
|
204
|
+
|
|
205
|
+
Parameters
|
|
206
|
+
----------
|
|
207
|
+
warehouse : str | uuid.UUID
|
|
208
|
+
Name or ID of the Fabric warehouse.
|
|
209
|
+
workspace : str | uuid.UUID, default=None
|
|
210
|
+
The Fabric workspace name or ID.
|
|
211
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
212
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
213
|
+
|
|
214
|
+
Returns
|
|
215
|
+
-------
|
|
216
|
+
pandas.DataFrame
|
|
217
|
+
A pandas dataframe showing a list of the columns in each table within the Fabric warehouse.
|
|
218
|
+
"""
|
|
219
|
+
|
|
220
|
+
from sempy_labs._sql import ConnectWarehouse
|
|
221
|
+
|
|
222
|
+
with ConnectWarehouse(warehouse=warehouse, workspace=workspace) as sql:
|
|
223
|
+
df = sql.query(
|
|
224
|
+
"""
|
|
225
|
+
SELECT t.TABLE_SCHEMA AS [Schema], t.TABLE_NAME AS [Table Name], c.COLUMN_NAME AS [Column Name], c.DATA_TYPE AS [Data Type], c.IS_NULLABLE AS [Is Nullable], c.CHARACTER_MAXIMUM_LENGTH AS [Character Max Length]
|
|
226
|
+
FROM INFORMATION_SCHEMA.TABLES AS t
|
|
227
|
+
LEFT JOIN INFORMATION_SCHEMA.COLUMNS AS c
|
|
228
|
+
ON t.TABLE_NAME = c.TABLE_NAME
|
|
229
|
+
AND t.TABLE_SCHEMA = c.TABLE_SCHEMA
|
|
230
|
+
WHERE t.TABLE_TYPE = 'BASE TABLE'
|
|
231
|
+
"""
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
return df
|