Starting in Looker 21.6, Looker is launching a new Liquid parser.
The parser is used during LookML validation and exposes Liquid syntax errors. This new parser is intended to prevent silent failures, make debugging Liquid syntax much easier, improve security of user attribute references and results caching, and more effectively detect dynamic field references. Because this parser introduces new checks for valid Liquid syntax, you may see new validation messages for existing Liquid syntax after you update to 21.6.
To avoid modeling disruption, the parser is being rolled out in phases over the coming months. It will initially be controlled by a legacy feature called Syntax Tolerant Liquid. This legacy feature does not affect use of the parser itself, but rather the level of the errors the parser exposes. When switched on, the feature will ensure that all errors are categorized as informational. When switched off, the feature will ensure that all errors are categorized as warnings, which may have implications for code commits, depending on the project’s Code Quality configuration.
In Looker 21.6, the Syntax Tolerant Liquid feature defaults to ON. In subsequent releases, it will be disabled by default and then eventually removed entirely. Refer to the deprecation schedule for details.
The new Liquid parser is not yet used for rendering Liquid in running queries, and new Liquid warnings raised during LookML validation will not surface at query runtime. The ability to use the new Liquid parser to render Liquid in running queries is still down the road; but when it arrives, it will ensure warning parity and query performance gains. Look for this feature in future release notes.
Interpreting Liquid syntax warnings
New Liquid syntax warnings are verbose and explicitly include the following information:
- The problematic input followed by the line and index number of the input within the Liquid block
- A link to the relevant LookML view file and code line
Take the example of the following error:
Error parsing liquid: Liquid parse exception: parser error "extraneous input '{{' expecting {Str, '(', '[', DoubleNum, LongNum, 'capture', 'endcapture', 'comment' 'endcomment', RawStart, 'if ', 'elsif', 'endif', 'unless ', 'endunless', 'else ', 'contains', 'case', 'endcase', 'when', 'cycle', 'for', 'endfor', 'in ', 'and', 'or' 'tablerow', 'endtablerow', 'assign', 'true', 'false', Nil, 'include', 'with ', 'empty','blank', EndId, Id, RawEnd}" on line 1, index 16 view_name.view:60 (project_name:view_name)
This warning amounts to the {{
input being inappropriately used within the {%...%}
tags on line 1 and at index 16 of the Liquid block on line 60 of view_name
. Liquid has rules for allowed inputs in this context, and those inputs are listed as:
{Str ,'(' ,'[' , DoubleNum , LongNum ,'capture' ,'endcapture' ,'comment' ,'endcomment' ,RawStart ,'if' ,'elsif' ,'endif' ,'unless' ,'endunless' ,'else' ,'contains' 'case' , 'endcase' ,'when' , 'cycle' ,'for' ,'endfor' ,'in' ,'and' ,'or' ,'tablerow' ,'endtablerow' ,'assign' ,'true' ,'false' , Nil,'include' ,'with' ,'empty' ,'blank' , EndId, Id, RawEnd}.
By removing the {{...}}
around value
, the liquid is parsed successfully!
Although the new warnings follow a structural pattern, there will be variations in message specifics. Below are examples of other variations, as well as some high level pointers for troubleshooting them.
Example one
Warning:
Error parsing liquid: Liquid parse exception: lexer error \ "token recognition error at: '(token)'\" on line x, index y
This can be thrown when an unexpected token, such as #
, is used:
Removing the unexpected token, #
in this case, should resolve the warning.
Example two
Warning:
Error parsing liquid: Liquid parse exception: parser error \ "mismatched input (input)|' expecting {TagEnd, '.', NEq, '==', '>=', '>', '<=', '<', '[', '?','contains', 'and', 'or'}\" on line x, index y
This can be thrown when functions are chained together with the |
token inside an if
conditional:
Assigning the output of the function chain to a variable and including that variable in the if
conditional should resolve the warning.
Example three
Warning:
Error parsing liquid: Liquid parse exception: parser error "missing '(character)' at '%}'" on line x, index y
This warning can be thrown when a necessary character, such as a closing parenthesis, is missing:
Adding the necessary character, a closing parenthesis )
in the example above, should resolve the warning.