Forum Discussion
Lakehouse Lookup Activity No Longer Shows T-SQL Query Option
Hi,
I have a Microsoft Fabric pipeline that uses a Lookup activity to execute a SQL query against a Warehouse and return a single value.
When I use a Lakehouse connection in the same Lookup activity, I can only select a table. The T-SQL Query (Preview) option is currently disabled. I was able to use this option approximately a month ago.
Is this functionality no longer supported for Lakehouse connections? What is the recommended approach for executing a T-SQL query against a Lakehouse from a Fabric pipeline and returning a single value, such as:
SELECT MAX(rec_mod_dtz) AS last_update FROM fact_survey_detail;
4 Replies
Hi Alaahady,
I have not seen a Microsoft statement on this specific change, so I cannot say whether the disabled option is intentional. In my understanding, the Lakehouse connection in a Lookup activity reads Delta tables directly, while T-SQL queries run against the SQL analytics endpoint, which is a separate connection. These are the workable routes for returning a single value:
Option 1: connect to the Lakehouse SQL analytics endpoint. Create a connection to the endpoint (server name from the Lakehouse settings) and use it from a Script or Lookup activity with a query:
SELECT MAX(rec_mod_dtz) AS last_update FROM dbo.fact_survey_detail;Option 2: Notebook activity. Run the query in Spark and return the value to the pipeline:
last_update = spark.sql("SELECT MAX(rec_mod_dtz) AS last_update FROM fact_survey_detail").first()[0] notebookutils.notebook.exit(str(last_update))The pipeline reads it with an expression such as:
@activity('Get last update').output.result.exitValueOne thing to keep in mind with Option 1: the SQL analytics endpoint syncs metadata from the Lakehouse, so a very recent write may show up with a short delay. If the pipeline runs right after a load, Option 2 avoids that.
So my overall approach would be:
Need freshness right after a load -> Notebook activity + exit value Simple read of committed data -> SQL analytics endpoint connection Table-only lookups -> Lakehouse connection as todayAI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.
Hi jubinsoni
Thank you for your kind support
The notebook work and was able to get the variable.
But I stuck again in the next step at Copydate, it seems that the connection to Lakehous is the main issue
To copy data with an on-premises or a VNet data gateway, ensure the destination connection enables 'Allow this connection to be utilized with either on-premises data gateways or VNet data gateways'. Please edit the connection to enable this option.
- ShafiUllah-bc
Helper II
Hi Alaahady,
jubinsoni already covered the two main routes. Just two small things that trip people up with the SQL analytics endpoint option:
- Create the connection as an Azure SQL Database connection, server = the SQL connection string from the endpoint settings, database = the Lakehouse name. Use Organizational account, basic auth won't work there.
- Always give the aggregate a column alias, otherwise the output is awkward to reference. With First row only ticked you read it as @activity('Lookup1').output.firstRow.<your alias>.
If the value has to be fresh right after a load, the notebook route is safer because of the endpoint sync delay.
Good luck with it.
Thank you for you kind support. I think you are correct, the main issue is the connection.
I've created a Lakehouse connection but still doesn't work
Al