This bash script will create a folder for every distinct file type/extension found in the project, and put any such files inside a folder along with altering the include
and file
statements so that the project continues to function.
In the folder-land project, includes statements can be relative, or absolute paths, so given this non-folder situation:
- master.model.lkml
- foo.view.lkml
- bar.view.lkml
- hello_world.dashboard.lookml
This script will modify the project to this folder situation:
- models/
- master.model.lkml
- views/
- foo.view.lkml
- bar.view.lkml
- dashboards/
- hello_world.dashboard.lookml
In the pre-folder situation, master.model.lkml’s include statement would look like: include: “*.view.lkml”
, but in the folderized world, it would need to be: include: “/views/*.view.lkml”
. The full rules for includes folder-includes statements can be found here.
-
The project will need to be in new LookML
-
Include statements are defined in a single line, e.g.:
- this will work:
include: "pizza.view" # some comments here
- this will not work:
include: # some comments # here "pizza.view"
- this will work:
-
Include statements require qualifying lkml file types with double quotes, e.g.:
- these will work:
include: "pizza.view"
,include: "pizza.view.lkml"
,include: "pizza*.view"
- these will not work:
include: "pizza*"
,include: pizza.view
- these will work:
- Clone your git repo locally
- Checkout your developer branch (make sure it's up-to-date with master)
- Run this script. Use the directory of your git project as the 1st argument, e.g.
./lookml_folderization.sh /path/to/repo
- Commit the change and push to origin/developer branch
- In Looker, Pull Remote Changes
- Validate LookML in Project
- Deploy to Production