Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
DennesTorres
Impactful Individual
Impactful Individual

Identify a shortcut in pyspark notebook

Hi,

 

Shortcuts are very powerful and they are a great feature to enable a data mesh architecture.

 

However, thinking on corporation level it may be hard to manage who links with who. How could we identify a shortcut in a notebook?

 

I already tried:

 

metadata

os.listdir

mssparkutils.fs.ls

show tblproperties

spark.catalog.listtables

 

Nothing worked, they follow the shortcut and give no cluet that's not a local table.

 

Fabric has the information, of course, it changes the icon for shortcuts and shows in the lineage. But how could we access this information in a notebook to improve our shortcut management?

 

Kind Regards,

 

Denne

5 REPLIES 5
Syliano
New Member

I resolve this by using sempy :

import sempy.fabric as fabric
import json
import requests
import fnmatch
import base64

-- Get metadata
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, StringType


# Récupérer les données depuis Fabric
ws = fabric.get_workspace_id()
items = fabric.list_items(workspace=ws)

# Construire une liste de dictionnaires à partir des données
items_data = [dict(row) for row in items.to_dict("records")]

# print(items_data)

# Définir le schéma (adapté selon vos colonnes)
schema = StructType([
    StructField("Id", StringType(), True),
    StructField("Display Name", StringType(), True),
    StructField("Description", StringType(), True),
    StructField("Type", StringType(), True),
    StructField("Workspace Id", StringType(), True),
])

# Créer le DataFrame Spark
items_df = spark.createDataFrame(items_data, schema)

# Créer une vue SparkSQL
items_df.createOrReplaceTempView("items_view")

-- get current lakehouse 

ws = fabric.get_workspace_id()
items = fabric.list_items(workspace= ws)
item = items[(items['Display Name'] == "Bronze")& (items['Type']=="Lakehouse")].iloc[0]["Id"]

-- call api

client = fabric.FabricRestClient()
r  = client.request(method="get", path_or_url=f"/v1/workspaces/{ws}/items/{item}/shortcuts")

-- update or créate shortcup to an other workspace

 

This code di you help you ?

 

Anonymous
Not applicable

Hi @DennesTorres  - Thanks for using Fabric Community,

I have reached the internal team for help on this. I will update you once I hear from them.

Appreciate your patience.

Anonymous
Not applicable

Hi @DennesTorres ,

Apologies for the delay in reply from our side. 

The fabric release plan states that this feature will be available during Q4 2023 (create and manage shortcuts via REST API): Link 

vgchennamsft_0-1698060534528.png

Appreciate your patience

Anonymous
Not applicable

Hi @DennesTorres ,

We haven’t heard from you on the last response and was just checking back to see if your query got answered? Otherwise, will respond back with the more details and we will try to help.

Anonymous
Not applicable

Hi @DennesTorres ,

We haven’t heard from you on the last response and was just checking back to see if your query got answered? Otherwise, will respond back with the more details and we will try to help.

Helpful resources

Announcements
May FBC25 Carousel

Fabric Monthly Update - May 2025

Check out the May 2025 Fabric update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.