Giter VIP home page Giter VIP logo

lookml-gen's Introduction

LookML Generator

https://travis-ci.org/symphonyrm/lookml-gen.svg?branch=master Documentation Status Updates

Programmatically generate LookML

Features

  • Generate LookML views programmatically
  • Include dimensions, dimension groups, filters, and measures in your views
  • Support Persistent Derived Tables (PDTs)
  • Write output to files or StringIO buffers

Quick Start

Install it:

pip install lookml-gen

Use it:

from lookmlgen.view import View
from lookmlgen.field import Dimension, DimensionGroup, Measure
from lookmlgen.base_generator import GeneratorFormatOptions

view_name = 'my_view'
v = View(view_name, sql_table_name='my_table')
v.add_field(Dimension('id', type='number', primary_key=True))
v.add_field(DimensionGroup('created'))
v.add_field(Dimension('name'))
v.add_field(Dimension('quantity', type='number'))
v.add_field(Measure('total_quantity', sql='${TABLE}.quantity', type='sum'))

with open('%s.view.lkml' % view_name, 'w') as f:
    v.generate_lookml(f, GeneratorFormatOptions(view_fields_alphabetical=False))

See it:

# STOP! This file was generated by an automated process.
# Any edits you make will be lost the next time it is
# re-generated.
view: my_view {
  sql_table_name: my_table ;;

  dimension: id {
    type: number
    primary_key: yes
    sql: ${TABLE}.id ;;
  }

  dimension_group: created {
    type: time
    timeframes: ["time", "date", "week", "month"]
    datatype: datetime
    sql: ${TABLE}.created ;;
  }

  dimension: name {
    sql: ${TABLE}.name ;;
  }

  dimension: quantity {
    type: number
    sql: ${TABLE}.quantity ;;
  }

  measure: total_quantity {
    type: sum
    sql: ${TABLE}.quantity ;;
  }
}

TODOs

Full LookML support is far from complete right now. At the moment only very basic aspects of Views and Fields are supported and there is no support for Explores yet. However, it does cover the most common functionality, including Persistent Derived Tables. The code can easily be extended and we'd love to get pull requests to fill out additional functionality.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

lookml-gen's People

Contributors

joeschmid avatar pyup-bot avatar michael-erasmus avatar cassandrateale avatar

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.