Question

Is there a way to set session context to the SQL code generated by Looker?

  • 25 August 2022
  • 2 replies
  • 36 views

Hi there,

I need to set session context  before the SQL code to be able to retrieve results from the DB.

sp_set_session_context N'AccountID', 1234;


SELECT TOP (500)
    account_v2.AccountId  AS [account_v2.account_id]
FROM 
    dbo.account  AS account_v2

 

How can I achieve this in Looker? 

So the session context must be set before the SQL code is run.

 

Can anyone help please?

 

Thanks

Ashwita

 


This topic has been closed for comments

2 replies

Also tried passing in the DB connection:

sp_set_session_context  @key = N'AccountID', @value = {{ _user_attributes['accountid'] }}

But I don’t get any results in the dashboard.

 

 

Looker support team has confirmed that there is no way to pass the session context variables from Looker. They have advised me to log a product request. Please give a thumbs up if you need this feature.

https://portal.feedback.us.pendo.io/app/#/case/200827?currentProductId=53ee6715-9dcb-471f-bd41-7846ac4d9e41