Question

Why are there multiple copies of the same PDT in my database?

  • 29 September 2015
  • 2 replies
  • 327 views

Userlevel 5
Badge

If you have multiple copies of PDTs based on the same view in your scratch schema, there could be a couple reasons:




  1. Changing the SQL of a derived table in developer mode and querying it builds a new copy of the table.


    This is only relevant when you change the SQL of the PDT, or the SQL in your dev mode is different than in production mode. Dev mode versions of tables are built when that PDT is queried, and last for 24 hours. This is equivalent to the dev mode table using persist_for: 24 hours.




  2. Prior to Looker 3.30 separate copies of a PDT were created for each model that PDT is included in.


    This means that if you have multiple models in the same project, and more than one model includes the view file containing that PDT, it will be built separately for each model. So, you might see many tables for the same PDT. As of Looker 3.30, multiple versions of a PDT will only be created when needed for some reason.


    In order to prevent many copies of the same PDT prior to Looker 3.30, consider being selective with which view files are included in each model. For example, instead of using


    - include: "*.view.lookml"

    consider listing the view files you want to include individually. Or, use a naming system for view files so that you can include all normal view files at once, but list the included PDTs separately, like so:


    - include: "table_*.view.lookml"
    - include: "pdt_one.view.looml"
    - include: "pdt_three.view.looml"



2 replies

Userlevel 1

Could you elaborate a bit more on the naming convention you suggest to prevent multiple copies of the same PDT from building? For example, I have two models in the same project that share a common PDT. I can see that multiple copies of the PDT are being built, while running a query from one of the models. Would I create two versions of the same PDT (i.e. PDT1 & PDT2) and use the include statement to select one version in each model separately?

Userlevel 5
Badge

Hey Anne - you would want to use a naming convention in the view files your PDTs live in, to denote that they are PDTs (along with a way to denote which files that are not PDTs). That way, you can include all normal views in all models, while only including the PDT files that you want in each model. To include all non-PDT files, you can do something like:


- include: "table_*.view.lookml"

Then, you can individually list the PDTs you want for each model. This is just a workaround to require less work listing each view file individually.


However, as of Looker 3.30, this shouldn’t be a problem into the future.

Reply