LookML Flashcards
What are the three types of files a LookML Project contains?
- Models
- Views
- LookML dashboards
In what file type are “Explores” defined.
Models
What 5 types of fields can a view contain
- Dimensions
- Measures
- Parameters
- Filters
- Field Sets
Describe the difference between an “object” and a “file”
A file ends with .lkml or .lookml
An object is something defined with code (e.g., “view: foo {}”
There are object models? T / F
False. There are only model files, unlike views, which can be a file or an object.
Should an include refer to the object name or the file name?
File name. E.g., “include: /views/your_mommas.view.lkml”
Is every file in Looker completely separate from the files?
Yes
Are there cases where it’s acceptable to have a view not match the file name?
Yes. For example, if we want to include a group of files, we may include the group name. E.g.,
view_name = "bobs" view_file_name = "people.bobs.view.lkml"
What happens if you include a model inside another model?
The LookML validator will throw an error about the connection being defined twice.
What are the two things “Explore” refers to in Looker?
- An “explore” is a LookML object that lives inside a model file. E.g., “explore: bobs_burgers {}”
- An “explore” is an interactive page where the standard user can SQL queries by clicking on fields in the UI.
What is the reason you don’t want to make your explore (object) contain too many views? What is the reason you don’t want to break explores apart too much? (too few views)
The user will be overwhelmed by the number of fields and options inside an Explore.
If you make Explores for every view, the user will be overwhelmed knowing what Explore to choose.
Balance.
Should you join a view you -think- you may need?
No. Only join what you will use. This saves clutter in the UI.
What is the difference between a “model” and “project”?
Models are LookML files that contain Explores Projects are collections of LookML files. A Project “owns” a model.
Can a project contain multiple models?
Yes.
Is the following valid SQL for a measure?
${orders.total} + ${bakesales.total}
Assuming both of these fields are measures of type: sum.
Yes. If the measure wrapping them is type: number. This tells Looker to add these fields, but not to aggregate them (i.e., not include the field in the GROUP BY).
If you add a measure as a filter and set it to > 0, what appears in the SQL to fulfill the filter?
Something like,
HAVING field_name > 0
When you make a change in development mode, what other users can see this change?
None. Unless they sudo you.
If you change the “Project Settings” in development mode, which users are impacted?
All users. The “Project Settings” impact the entire project–not just your development branch.
Is “Production Mode” LookML read-only? T / F
True.
What happens if you have a view which extends another view, neither view has an sql_table_name defined?
The LookML parser assumes the table name matches the view name. If it does not, it will through a DB error.
dimension: view:, type:, sql: are all examples of what?
LookML parameters.
The ${} is referred to as what?
Substitution syntax. It replaces anything inside ${} with a corresponding object.
What is the purpose of using substitution syntax?
Reduces the number of changes which need to be made throughout a model.
Why is it important to use the substitution operator? I.e., ${}?
- It makes LookML code more reusable.
- It simplifies code maintenance.
- It removes the need for the same SQL code to be written multiple places (DRY).
What does ${TABLE} become?
The table defined in the sql_table_name. Or, the name of the view if the sql_table_name parameter is not defined.
If you create a dimension_group called “start” with the type “time” and timeframes [raw, time, date, month, year], how would you refer to the month?
${start_month}
If you create a dimension_group called “start” with the type “time” and timeframes [raw, time, date, month, year], which of these fields would not show in the UI?
${start_raw} would not show in the UI.
T / F – A dimension_group of type: time automatically adjust for user’s timezone?
True
What are the required parameters of a dimension_group of type: duration? (other than the type).
- sql_start:
- sql_end:
- intervals: []
Given the following dimension_group:
dimension_group: created { type: duration interval: [ day, week, month, year ] sql_start: ${created_date} sql_end: ${created_date} }
How would you refer to the number of days in a custom filter?
The interval part goes first:
${days_created}
Consider the following dimension:
dimension: in_house {
type: yesno
sql: ${TABLE}. in_house ;;
}
What will show in the UI when
- in_house = 1
- in_house is NULL
- in_house = “no”
- in_house = 0
- in_house = “Yes”
- in_house = “No”
- in_house = “Yes”
- in_house = “No”
Consider the following dimension:
dimension: age_tier {
type: tier
tiers: [0, 30, 50]
sql: ${TABLE}. age ;;
}
What is the category label for someone
- ${TABLE}. age = -1
- ${TABLE}. age = 30
- ${TABLE}. age = 49
- ${TABLE}. age = 55
- “Below 0”
- “31 to 49”
- “31 to 49”
- “50 or Above”
Consider the following dimension:
dimension: age_tier {
type: tier
tiers: [0, 30, 50]
sql: ${TABLE}. age ;;
}
What parameter and value should be added to have the values show as numbers?
style: integer
Consider the following dimension:
dimension: age_tier {
type: tier
tiers: [0, 30, 50]
sql: ${TABLE}. age ;;
}
Could you add both a style and value_format parameters?
Yes.
What are the 5 built in map_layers which Looker provides?
- countries
- uk_postcode_areas
- us_states
- us_counties_fips
- us_zipcode_tabulation_area
What are the required parameters for a dimension of type: location?
- sql_latitude
* sql_longitude
What format does a custom map layer file need to be in?
TopoJSON
If no type is provided to a dimension, what type will it be?
String.
You have a sale_price dimension and a cost dimension. If you wanted to create a profit dimension that subtracts cost from sale_price, what type would you specify for this new dimension?
number
When should a type: count_distinct be used on a measure?
When counting a unique field which is not the primary key in a table.
What is wrong with this measure definition:
measure: order_items {
type: count
sql: ${order_items} ;;
}
The measure does not need to include sql: parameter, as the primary key will be used to perform a count.
What is wrong with this measure definition:
measure: order_items {
type: count_distinct
}
A measure of type count_distinct must include a sql: parameter, as it will be used to perform the distinct count.
What are the 4 types of formatting for the value_format_name parameter?
- ID (id)
- Decimal (decimal_0, decimal_1, decimal_2, decimal_3, decimal_4)
- Currency (usd, usd_0, gbp_0, gbp, eur, etc.)
- Percents (percent_0, percent_1, etc)
T / F – Can a user access this dimension?
dimension: order_id {
hidden: yes
sql: ${order_id} ;;
}
Yes. The “hidden:” parameter only impacts whether the field will show in the UI, it is still accessible in custom filters, custom dimensions, etc.
How many database connection can a model file have?
One.
T / F – Looker production mode is read-only
True
What is the keyboard shortcut for toggling dev mode?
CMD / CTRL + SHIFT + D
What are the two things a model file defines?
- Database connection
2. Explores
What is one of the primary advantages of LookML dashboards?
They are defined LookML and therefore version controlled.
How do you define navigation in a Looker document file
At the front matter of the document use YAML to define it as a navigation enabled document. --- navigation: - document_one - document: document_two label: Customized Label for Document Two - section: My Section Name - document_three ---
What all can be defined in a manifest file?
- project imports (remote or local)
- model localization settings
- LookML constants
- Extension definitions
- Custom visualization definitions.
Where should the manifest.lkml file be located in the project directory?
It can -only- be stored in the root directory.
When is a manifest_lock.lkml file added?
When a remote dependency is added to the project.
What is the appropriate (but not required) file extension for an explore file?
.explore.lklml
E.g., my_explore.explore.lkml
Is LookML case sensitive.
Yup!
my_dimension != My_DIMENSION
When you move a LookML file from one folder to another in the IDE, what does its Git history look like?
It is blank. When moving a file, the IDE deletes it and creates a new file in the new directory.
Can you bulk delete views not in a directory?
Yes, the IDE has a bulk deletion option.
Given the path “/views/business_views/new_views”
How would you create an include statement to include all .lkml files in the “/views/business_view” and /views/business_views/new_views”
include: “/views/**/*.lkml”
The double asterisk is a recursive wildcard.
What does Looker cache?
Looker caches the results of every query run. Queries can be run from explores, Looks, dashboards, and schedules.
Does Looker cache dashboards?
No. But it does cache the queries on a dashboard.
What is the default cache duration?
1 hour, unless overridden by a caching policy.
What happens if the Looker cache fills up?
The oldest results will be dropped to make way for new results.
What is the recommended way to control caching behavior?
Looker recommends to use Datagroups.
Other than “label” and “description,” what are the other two parameters: on a datagroup.
- max_cache_age:
2. sql_trigger:
T / F – Datagroups can contain a description?
True. The option description: should explain the datagroup’s purpose.
How many rows can the sql in a sql_trigger parameter return?
One.
What is the result of a sql_trigger compared to determine if it is triggered?
The sql_trigger results are compared to the previous results. They must be different to trigger.
What timezone do sql_trigger dates use?
They are not adjusted by Looker; they will be the timezone set in your database.
How does sql_trigger_value: work in dev mode?
Any sql_trigger_value becomes replaced with persist_for: “24 hours” no matter what setting.
What are the 3 intervals allowed in a max_cache_age?
- seconds
- minutes
- hours
What’s the difference between max_cache_age and persist_for when assigned to a PDT?
max_cache_age only invalidates the results (deletes the cache), it does not cause the PDT to rebuild.
persist_for invalidates the PDT and rebuilds it.
Pro tip, if you define a datagroup with only max_cache_age, a derived table assigned that datagroup will persist, but because there is no trigger assigned, the PDT will sit in the scratch schema indefinitely.
What parameter is used in an explore: to apply a datagroup caching policy?
persist_with:
E.g.,
explore: my explore {
…
persist_with: name_of_datagroup
How can you control the default caching policy for all explores?
Define a datagroup for the caching policy and add persist_with: at the model level. This should cascade to all explores.
What is the default interval which a sql_trigger runs at
Every 5 minutes. It can be overridden in the connections.