Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skokenes/0018978886a090974c7a3b43f69aceed to your computer and use it in GitHub Desktop.
Save skokenes/0018978886a090974c7a3b43f69aceed to your computer and use it in GitHub Desktop.
A proposal for a Qlik Core CLI tool for quickly working with QVFs

Proposal

A CLI tool that leverages Qlik Core to report on basic metadata about a QVF.

Motivation

Qlik Core leverages QVF files to store data models that you can interact with via the Qlik Associative Engine. These QVF files, like any file, are black boxes until you open them up and look inside. While developing solutions on top of Qlik Core, it can be difficult to understand what is going on with your QVF - what data is in there, what objects, etc. Writing scripts via enigma.js or RxQ to simply get a list of fields from a QVF that you are building on top of is cumbersome.

Eventually, I expect that Qlik, partners, and customers will build an ecosystem of nice dev tools for working with Core. In the meantime, I propose a CLI tool as a first step that can provide key metadata about QVFs in a quick and easy way.

Existing Solutions

There are no published solutions (that I'm aware of) today for easily working with Core across platforms. Alex Karlsson and Stefan Walther have indicated that they have some unpublished solutions that address these needs.

If you have access to Qlik Sense, it can be used to do some of these basic tasks. You can also leverage Rob Wunderlich's QS Document Analyzer, which gives a lot of this metadata. However, these solutions require both access and understanding of the Sense platform to make use of them. They may not be beneficial for a web or software developer who has no Sense background. Nor do they fit cleanly with a developer workflow that exists outside of a Qlik Sense context.

Example Scope

Most of the questions that I have while working with a QVF in Core are basically about its contents. Usually this is to either confirm that the QVF is set up as expected, or to get some insight on what I can leverage from it.

Specifically, I find myself asking questions like:

  • What are the fields in this app?
  • What are the tables and their relationships?
  • What are the GenericObjects? Bookmarks? etc...
  • What is the cardinality of a field?
  • What are some sample values in a field? In a table?
  • Do my calculations work? Does the data look as expected when I put some aggregations together?

Example API

Below is a rough approximation of what an API might look like for this tool.

Starting Session with App

From a terminal, navigate to a folder with some QVFs in it and run:

$ qli myApp.qvf

to start a Qlik Core session with that app. This will create an ongoing process where you can continue to enter commands that will be executed against the app. The following commands are executed from this process, after you've run the start command above to initiate a session.

Get lists of things

fieldlist

objectlist

dimlist

etc. This could take a parameter for filtering the list. For example, you may want an object list of objects with a certain qType:

objectlist -t myType

Get the data model structure

tablesAndKeys

This would return a list of each table and the fields in that table. Additional metadata about the fields might be useful, like data types. Parameters could be added to control exactly what you get back. tablesAndKeys may not be the best name, it maps back to the API but something like datamodel might be more obvious.

Field cardinality

cardinality "Field Name"

Field values

elements "Field Name"

Properties

properties "Field Name"

properties "object-id"

There probably needs to be a way to tell it what type you want to pull properties for (field vs generic object, etc). So an additional parameter might be needed

Layout

layout "object-id"

While I don't see this tool as an effective way to explore the associative data, a basic ability to get a layout on demand would be a useful debugging tool

Current Selections

selections

Select in a field

select "Field Name" "value to select"

Previewing aggregated data

preview -d "Dim1" "Dim2" -m "sum(Sales)"

This could return you a qMatrix with a subset of rows from a hypercube with those columns. This would be a quick way to validate that your data is loaded and associated properly

Peek at model data

peek "tablename"

Returns a subset of rows from a table in your data model.

These are just a few ideas; For now I've basically kept out the concept of changing the QVF structure from the CLI. It could be useful, but I am not sure how you easily accomplish this in the API. For example, how would you write a generic object definition that you want to add to the QVF? What about a load script? Just copy and paste it in?

Next Steps

I'm looking feedback on this proposal to decide if and how an open source project should be started. Please leave comments with your thoughts.

@countnazgul
Copy link

Lets try and move the conversation here rather than Tweets :)

First of all i think that such tool is needed. At least i need it ;) I'm trying to build something on my spare time and was planning to have similar functionality.

As final output it should be CLI and GUI. CLI is faster to build so we can have something at hands quickly. The graphic element will be much better option especially when displaying relationships (for example)

@skokenes
Copy link
Author

skokenes commented May 2, 2018

@countnazgul I agree. I'd love to have some killer GUI tools for this. for now, a simple CLI with a few commands will go a long way. What kind of commands would you find immediately useful?

@countnazgul
Copy link

very basic ones are good start. list of fields, tables, row counts (fields and tables)

btw any thoughts of programming language (for the cli)?

@gsbeaton
Copy link

gsbeaton commented May 2, 2018

Quite excited about the potential of this. If you're looking for some starter commands (I've borrowed most of these from mySQL and admittedly, not put a lot of thought into them but happy to map this into something closer to a specification if we take this forward).

Discovering table data
qli abc.qvf
show Tables
use Table
describe fields
select field from Table

We could use a similar process to discover objects
show Sheets
use Sheet
describe objects (list objects on sheet including some useful metadata eg, chart type, count of dimensions and measures used)
use object
show dimensions|measures

And some global commands
show variables|expressions|key fields|current selections

If we want to go deeper now, the ability to test an expression
execute sum(Sales)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment