Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/sempy_labs/_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,19 @@ def resolve_warehouse_id(

return resolve_item_id(item=warehouse, type="Warehouse", workspace=workspace)

@log
def resolve_warehouse_name_and_id(
warehouse: str | UUID, workspace: Optional[str | UUID] = None
) -> Tuple[str, UUID]:

workspace_id = resolve_workspace_id(workspace)
type = "Warehouse"

(warehouse_name, warehouse_id) = resolve_item_name_and_id(
item=warehouse, type=type, workspace=workspace_id
)

return warehouse_name, warehouse_id

def get_language_codes(languages: str | List[str]):

Expand Down
23 changes: 17 additions & 6 deletions src/sempy_labs/lakehouse/_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pandas as pd
from sempy_labs._helper_functions import (
resolve_lakehouse_name_and_id,
resolve_warehouse_name_and_id,
resolve_workspace_id,
resolve_workspace_name_and_id,
_base_api,
Expand Down Expand Up @@ -39,9 +40,9 @@ def create_shortcut_onelake(
table_name : str
The table name for which a shortcut will be created.
source_lakehouse : str | uuid.UUID
The Fabric lakehouse in which the table resides.
The Fabric lakehouse or warehouse in which the table resides.
source_workspace : str | uuid.UUID
The name or ID of the Fabric workspace in which the source lakehouse exists.
The name or ID of the Fabric workspace in which the source lakehouse or warehouse exists.
destination_lakehouse : str | uuid.UUID, default=None
The Fabric lakehouse in which the shortcut will be created.
Defaults to None which resolves to the lakehouse attached to the notebook.
Expand Down Expand Up @@ -74,9 +75,19 @@ def create_shortcut_onelake(
source_workspace
)

(source_lakehouse_name, source_lakehouse_id) = resolve_lakehouse_name_and_id(
lakehouse=source_lakehouse, workspace=source_workspace_id
)
error = None
source_type = 'lakehouse'
try:
(source_lakehouse_name, source_lakehouse_id) = resolve_lakehouse_name_and_id(
lakehouse=source_lakehouse, workspace=source_workspace_id
)
except Exception as e:
error = e
if error:
(source_lakehouse_name, source_lakehouse_id) = resolve_warehouse_name_and_id(
warehouse=source_lakehouse, workspace=source_workspace_id
)
source_type = 'warehouse'

(destination_workspace_name, destination_workspace_id) = (
resolve_workspace_name_and_id(destination_workspace)
Expand Down Expand Up @@ -144,7 +155,7 @@ def create_shortcut_onelake(
)

print(
f"{icons.green_dot} The shortcut '{shortcut_name}' was created in the '{destination_lakehouse_name}' lakehouse within the '{destination_workspace_name}' workspace. It is based on the '{table_name}' table in the '{source_lakehouse_name}' lakehouse within the '{source_workspace_name}' workspace."
f"{icons.green_dot} The shortcut '{shortcut_name}' was created in the '{destination_lakehouse_name}' lakehouse within the '{destination_workspace_name}' workspace. It is based on the '{table_name}' table in the '{source_lakehouse_name}' {source_type} within the '{source_workspace_name}' workspace."
)


Expand Down