Querying Views or PDTs in SQL Runner

  • 13 July 2017
  • 2 replies

Hi - fairly new to looker so appreciate the advice here.

I want to be able to query a view or PDT from sql runner. That way, I can run a query in SQL runner in a few lines of code (e.g. SELECT * from view1 LEFT JOIN view2 USING (id)), but that code would represent arbitrarily complex logic (e.g., if pdt1 and pdt2 are themselves generated from queries each 500 lines of code).

Is this possible? An obstacle I keep running into is wanting to query on the fly in sql runner but not able to abstract away large, recurring subqueries.


2 replies

Userlevel 1

I’m not sure if this answers your question, but yes, you can query PDT’s in SQL Runner. However the name of the table to query is not obvious - you can find actual PDT names in the list of tables in the “looker_scratch” schema (or whatever schema you have told Looker to put the PDT’s in) - but those names will change as the PDT’s are re-derived.

@aqm As mentioned by the previous comment, yes you can query a PDT in SQL Runner. Either through finding the exact temp table (scratch schema) where the PDTs are written. Seeing as your newer, have you used the Open in SQL Runner button? When on an Explore, you can choose all the necessary dimensions and measures and then you can open that automatically generated SQL code in SQL Runner and then add / edit additional SQL as needed.

I recommend that you review the documentation here for SQL Runner background and tips.