Coder Social home page Coder Social logo

metriql-lookml's Introduction

metriql Looker Integration

Generates LookML model from your metriql datasets. The idea is to leverage metriql datasets in your Looker setup without any additional modeling.

Usage

The library is available in PyPI so you can install it via pip as follows:

pip install metriql-lookml

The library expects stdin for the metriql metadata and outputs a ZIP file to stdout. Here is an example:

curl http://metriql-server.com/api/v0/metadata | metriql-lookml --connection myproject > metriql.zip

You can use --file argument instead of reading the metadata from stdin as an alternative.

The command outputs a zip file to stdout by default, if you pass --out myfile.zip argument, it will write to the specified file instead.

How does it work?

  1. Create a connection to metriql from Looker using its Trino interface.

  2. Run metriql-lookml passing the relevant connection argument for metriql.

You need to enable JDBC in your metriql server to be able to use metriql's Trino interface.

Build from source

Requires pipenv and python >=3.7

# From root folder
# Install
pipenv install --dev

# Run
pipenv run metriql2lookml

metriql-lookml's People

Contributors

buremba avatar umarmajeed-rana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

emresemercioglu

metriql-lookml's Issues

Support downloading files as a zip file

We will call this library from our web app and let people generate LookML projects locally if they wish so. In order to integrate with the web app, the users need to be able to download the LookML files as a zip file. Here is how it looks like: https://cln.sh/wVY9s9

We can have a command-line argument called --stdout that outputs a zip file to stdout so that we can call the Python library from our application or the users can run the following command:

metriql-looker --stdout > files.zip

Implement timeframes

Looker supports dimension groups for different time and duration values. While metriql doesn't support duration yet, we should generate appropriate LookML that lets people to drill down into different time buckets. If we have a dimension as follows:

name: created_at
column: created_at
timeframes: [day, week, month]
type: timestamp

We should generate the following LookML:

view: view_name {
  dimension: created_at__day {
    label: Day
    sql: ${TABLE}.created_at::day ;;
    group_label: "Created At"
  }
  dimension: created_at__week {
    label: Week
    sql: ${TABLE}.created_at::week ;;
    group_label: "Created At"
  }
 dimension: created_at__month {
    label: Month
    sql: ${TABLE}.created_at::month ;;
    group_label: "Created At"
  }
}

Since we don't want Looker to take care of the timeframes themselves, we create different dimensions and group them using the group_label attribute.

Publish library to pip

We should publish the library to PyPI and let people install the library and run them locally as follows:

pip install metriql-looker
metriql-looker [ARG]

Rather than creating one model for each dataset, let’s create a single file

  1. If the description is an empty string, let’s ignore it
  2. Rather than creating one model for each dataset, let’s create a single file called explores.model and include all the explores.
  3. Here is an example:
connection: "Project Name"
include: "/views/*"
explore: source_snowflake_tpch_sample_tpch_orders {
  description: ""
}
explore: source_snowflake_tpch_sample_tpch_customers {
  description: ""
}
  1. We should probably implement command line arguments for changing the name but the default will be explores

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.