-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(looker): represent looker views dependencies from substitution (#…
…21806) ## Summary & Motivation Parse the Looker substitution syntax ($) using regex. See [https://cloud.google.com/looker/docs/sql-and-referring-to-lookml#substitution_operator_](https://cloud.google.com/looker/docs/sql-and-referring-to-lookml#substitution_operator_) for more details. This is similar to how dbt parses their jinja model templates. If raw, non-templated tables are included in the SQL alongside templated Looker views from Looker substitution, we will only provide the templated Looker views as upstream dependencies. For SQL definitions that only use non-templated tables, we will still parse them using `sqlglot`. And with SQL definitions that only use non-templated tables, but have [Liquid templating](https://cloud.google.com/looker/docs/liquid-variable-reference), no parsing will occur. ## How I Tested These Changes pytest
- Loading branch information
1 parent
3c9a26d
commit c6536b3
Showing
4 changed files
with
164 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ests/looker_projects/test_exception_derived_table/views/exception_derived_table.view.lkml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
view: exception_derived_table { | ||
derived_table: { | ||
sql: | ||
SELECT | ||
* | ||
FROM `looker-private-demo.retail.us_stores` | ||
WHERE 1=1 | ||
{% if _model._name == 'thelook' %} AND 1=1 {% endif %};; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters