Parser for new LookML?

  • 21 December 2017
  • 5 replies

Userlevel 6

Yes, please!

Introducing Node LookML Parser -

(Disclaimer: I made this myself - it is provided 100% as-is, without warranty, and probably unwarranted!)

It’s an open-source Nodejs module which can be used from the command line, or as a dependency in your Nodejs application. It can process either a single string of LookML, or a whole directory of files, and outputs the results into an easy-to-navigate JSON-compatible object.

Here’s what it looks like on the command line:

5 replies

Cool! Thanks for doing this. We may not need it as much as we did previously, now that branches can be named (along with a couple other 5.x features), but I’m glad to know there’s a way to do our workarounds if we need to.

Any idea what it would take to round trip something through this? E.g., we want to change all the model names in a set of files; so we want to read, find those, then write out a new .lkml that gets them right.

Userlevel 6

@cobbr2 I’ve made a couple of JSON object -> LookML generators for specific use cases before, and I think the approach should be generalizable. I just use a templating language (of which there are dozens, I like DoT).

Here are some in-browser implementations to give you an idea of what I mean:

I’ve started one parse->transform->generate tool in Node too, but haven’t finished it yet.

If all you’d like to do is change something highly-localized like explore names, maybe a simple regex search&replace would be sufficient?

Userlevel 3

this is awesome!

i’ve been looking for more CLI stuff for editing lookml, as our main project has grown so large that editing lookml in-browser is an awful experience.

specifically, i’m interested in using this to be able to parse our lookml dimensions for a known set of acronyms to ensure we’re including labels in those dimensions so they display properly.

Userlevel 6

I just published an update to the package that improves the output a little bit (details on the npm page)