A style guide and linter for Looker's LookML data modeling language
View the Project on GitHub looker-open-source/look-at-me-sideways
v1 of LAMS was developed at a time when few LookML developers had continuous integration (CI) infrastructure set up for their LookML projects. As a result, LAMS targeted a markdown output format for maximum interoperability from Looker’s IDE.
In addition, it tried to fit several distinct use cases into that markdown output: reporting issues/recommendtions, summarizing exemptions, and listing tables by primary key (ostensibly for organizational & navigational benefits).
As more LookML developers adopted a CI pipeline, it became clear that most consumers were looking primarily for a pass/fail indicator and an a listing of failures that was easily consumable via their CI tooling.
With the v2 release of LAMS, the possible output modes have been expanded and modularized, so that consumers can explicity state which output mode(s) are best for them. In addition, LAMS will emphasize a new output mode that is designed to be more accessible from a typical CI tooling context: output goes to the command line’s standard output, rather than to a file, and with a tabular human-readable output with one message on each line, instead of markdown.
output parameter to toggle between output modeslines output mode: human-readable tabular output to the CLI with 1 line per messagelines mode. To preserve v1 functionality, use --output=markdown,developerMarkdown--on-parser-error=infomanifest CLI argumentnode_modules/**, for cases where LAMS may be installed as a local dependency, so that its own test files will not be picked up._rendered_value. See issue 118manifest.rule.F4.options.v3_dimension_groups:yes_link in rule F1.V3 of LAMS is a big change that brings on board many of the underlying LookML Parser’s output options that have accumulated over time: whitespace awareness, extension/refinement support, a simplified file representation, and imported project support.
The broad overhaul that this required for built-in rules also presented an opportunty. Many of the built-in rules have been made more streamlined and consistent. But, most importantly as of 3.0, built-in rules will be opt-in rather than opt-out. These two changes will greatly improve the ability to publish new built-in rules and patch existing built-in rules without unduly burdening existing LAMS users.
As a result, users upgrading to 3.0 should expect to paste a simple declaration into their manifest to opt-in to each built-in rule.
Beyond that rote change, the primary impact will be to LAMS users who have implemented custom rules, who may have to update their rules for the updated LookML representations.
Usage of LAMS that only uses the built-in style guide rules should not see a large impact, except that some rules may now work correctly based on extensions/refinements, whereas they may have thrown “false positive” errors previously because the parser did not apply any extensions/refinements.
model construct. The file construct continues to provide the lexical / “as written” representation.$strings property within each object. An initial built-in rule pertaining to whitespce, W1, is also included in the initial release as an example.$strings whitespace data is now available#LAMS declarations, like rule: F1 {} to opt-in to a rule. A sample declaration to opt-in to all rules is provided in the readme.[A-Z][0-9]+ are nominally reserved for built-in rules, if you’ve written a custom rule whose name overlaps with a built-in rule, you can mark the rule as custom: yes to disambiguate.T2. You may still apply exemptions for individual sub-rules if you wish, though in some cases, dependencies between the sub-rules means that not all parts of the rule will always be evaluated.jsonpath, which was rarely maintained, to jsonpath-plus. This is primarily to address the old library’s failure to correctly match union expressions, which were a common use case for expressions like $.model.*['dimension','measure'].*For any error not detailed below, please submit an issue!
$.files.* to $.file.*. Note that the path/location will now contain the filename.This update introduces, as beta features, centrally managed exemptions, and an add-exemptions output mode. Together, these features serve to enable incremental linting use cases.
Feedback on these beta features and the overall incremental linting use case is welcome in issue #142.
lams-exemptions.ndjson in a newline-delimited JSON format.output=add-exemptions can append any errors from the current run as new exemptions in the lams-exemptions.ndjson file.New rules available. Make sure to add them to your manifest.lkml to opt-in. An updated sample snippet to opt-in to all rules is provided on the main README page.
primary_key. K7 detailsprimary_key must be or use PK-named dimension(s). K8 detailsforeign_key-based joins are many_to_one. E6 detailsPatches:
LookML Dashboards are now supported. This functionality is disabled by default. To enable it, also install js-yaml, and including dashboard file pattern into your source argument. (Note: no built-in rules currently relate to dashboards, but you may apply custom rules to them)
allow_exemptions argument for rules to specify if they do not want to allow exemptionsrule_exemptions: {rule: "reason"} syntax is still supported, though no longer emphasizedPatches:
v3.4.0 had introduced a change in behavior at the intersection of conditional comments and whitespace rule W1. Since whitespace behavior for conditional comments had not been formally defined or desrcribed, this release defines the conditional comment whitespace handling going forward, primarily chosen to mirror the in-Looker IDE behavior when a block is commented via the Ctrl+/ shortcut. Conditional comments will preserve the whitespace before the comment, consume the comment character and up to one space or tab character following the comment character and/or conditional comment token.
/ ) pathoptionsPatches:
⚡ icons below indicate breaking changes.
github-job-summary for GitHub usersonParserError option was removed. Parsing errors now always result in error-level messages. For use cases where parsing errors should be ignored, users can instead use global or central exemptions on rules P0 and P1.model object inserted into the top-level of model files (i.e., under the file object). For example, previously, the output may have contained a path like $.file['my_model.model'].model.my_model.explore.foo, and would now simply contain a path like $.file['my_model.model'].explore.foo. Any custom rules that attempted to match this previous construct should be updated. That said, I expect most use cases will instead use the top-level (non-file) model object, rather than the file object.path argument./ or : characters, which notably may be present in file paths. All path elements in location properties must now escape any /, :, or \ characters with a preceding backslash (\)5.1.0 accidentally included breaking lookml-parser representation changes for custom rules and has been re-released as 6.0.0. Please upgrade to 6.0.0 (or pin to 5.0.x if you are not ready to update custom rules).⚡ icons below indicate breaking changes.
lookml-parser to ^9.3.1. This introduces breaking LookML representation changes for custom rules
$strings metadata has a redesigned structure.lookml-parser changelog for all changes and details.P (P0–P4): P0 and P1 remain enabled by default, while P2, P3, and P4 are opt-in via manifest.lkml.F8: Suggests value_format_name (id or usd_*) for non-hidden numeric fields that appear to be IDs or USD currency values.F9: Enforces a configurable maximum length (default 30 characters) on non-hidden field names/labels.F10: Validates that suggest_explore and suggest_dimension reference explores and dimensions available in the model.F11 and E8: Validate that "NOT NULL" vs "-NULL" filter expressions match the target field’s type (string vs numeric) in filtered measures and explore always_filter/conditionally_filter.F12: Checks field alias declarations (including dimension_group expansions) for conflicts with other aliases or field names within the same view.before_all (expr_init, match, expr_reduce) support for pre-computing shared state/indexes once per rule run in custom and built-in rules.T3 (T3.1–T3.3) and E4: Table-backed views (sql_table_name or PDTs) exposed as the base of a non-hidden explore should declare #LAMS required_filter: <field_name> (or assert a maximum row count via a data test), and explores based on such views must enforce that filter via always_filter.T11: Requires unguarded MIN, MAX, and ANY/ANY_VALUE aggregates in derived tables to use an explicit alias indicating min/max/any (configurable via min_fragments, max_fragments, any_fragments options).T14: Disallows Liquid/dynamic SQL in persisted derived tables (except ``).T15: Flags bare UNION in derived tables and sql_table_name subqueries unless UNION ALL, UNION DISTINCT, or an accompanying comment (such as UNION /*DISTINCT*/) is used.E5: Flags many_to_many joins and branching one_to_many join paths within an explore to prevent multiplicative fanout.?? coalesce shorthand, $get? optional chaining, and $is-hidden (respecting fields_hidden_by_default) for custom rules written in LIYAD.F4, F8, F9, and K4 now respect view-level fields_hidden_by_default.K1: Allow dimension_group with raw timeframe to satisfy the primary key naming convention.K3: Allow a primary_key: yes dimension to be declared before pk{n}_ primary key dimensions.E2: Allow UNNEST(...) joins (via join.sql or join.sql_table_name) without requiring primary key equality constraints, and default to strict_mode: no (accepting primary_key: yes dimensions and DT GROUP BY/SELECT DISTINCT column sets in addition to pk{n}_ naming; set options: { strict_mode: yes } for legacy strict behavior).K7: Fixed a runtime error (Cannot convert undefined or null to object) when a table-backed view has no dimensions.