Use with Looker
SelectJoin can write a LookML view for each model, so the tables your models build are ready to explore in Looker. Like every SelectJoin command, the export works from files and connects to nothing.
Export views
Section titled “Export views”selectjoin export lookml --output path/to/looker_project --schema analyticsThis writes one view per model in the marts layer into views/selectjoin/:
# Generated by SelectJoin from models/marts/mart_customer_revenue.py.# Completed-order revenue per customer.# Do not edit: change the Python model and export again.view: mart_customer_revenue { sql_table_name: analytics.mart_customer_revenue ;;
dimension: customer_id { primary_key: yes type: number sql: ${TABLE}.customer_id ;; }
dimension: customer_name { type: string sql: ${TABLE}.customer_name ;; }
dimension: order_count { type: number sql: ${TABLE}.order_count ;; description: "Number of completed orders." }
dimension: net_revenue { type: number sql: ${TABLE}.net_revenue ;; description: "Revenue after order discounts." }
dimension: loyalty_adjusted_revenue { type: number sql: ${TABLE}.loyalty_adjusted_revenue ;; }
measure: count { type: count }}Options
Section titled “Options”| Option | Description |
|---|---|
--output PATH |
The Looker project directory. Views go in views/selectjoin/. |
--layer LAYER |
Export the models of one layer. Default: marts. |
--all |
Export every model instead of one layer. |
--schema NAME |
The schema the tables are built in, used in sql_table_name when a model’s relation has none. |
--dialect D |
SQL dialect for table names and the composite key expression. |
--force |
Replace previously exported files. Without it, existing files are never touched. |
What maps to what
Section titled “What maps to what”| SelectJoin | LookML |
|---|---|
| Model | view, with sql_table_name from the model’s relation or its name |
| Numeric column | dimension with type: number |
| Boolean column | dimension with type: yesno |
| Text and other columns | dimension with type: string |
| Timestamp column | dimension_group with type: time |
| Date column | dimension_group with type: time, datatype: date, convert_tz: no |
| Single-column grain | primary_key: yes on that dimension |
| Composite grain | A hidden primary_key dimension that concatenates the grain columns |
| Column description | description on the dimension |
| Model description | A comment at the top of the file |
A dimension group is named after its column without a trailing _at, _on, _date, _time, or _ts, so ordered_at gives Looker ordered_date, ordered_week, and so on.
Every view also gets a count measure. Sources, ephemeral models, and models from packages are not exported, because SelectJoin does not build a table for them.
Describe columns
Section titled “Describe columns”Descriptions come from the model:
@model( layer="marts", grain="customer_id", description="Completed-order revenue per customer.", column_descriptions={ "order_count": "Number of completed orders.", "net_revenue": "Revenue after order discounts.", },)def build(ctx): ...column_descriptions is checked like everything else: a name that is not an output column fails selectjoin check with a suggestion. The same descriptions appear in selectjoin inspect --json and in the dbt export.
Limits
Section titled “Limits”- Measures other than
countare not generated. Add them in a view that extends the exported one, so your edits survive the next export. - Explores and joins are not generated.
- Descriptions do not carry over from upstream models. Describe a column on the model you export.
- Column names that are plain lowercase identifiers are written unquoted. On warehouses that fold unquoted names to upper case, such as Snowflake, check that this matches how the table was created.
- The exported LookML was checked with a LookML parser, not in a Looker instance.