Skip to content

Commit

Permalink
Fixes+ added pure SQL output
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Zasadzinski committed Apr 4, 2019
1 parent d824808 commit 4d626e2
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 168 deletions.
19 changes: 6 additions & 13 deletions examples/cars_on_parking/parking.lkml
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
include: "parking.view"

explore: parking {
view_name: parking
from: parking
label: "parking explore"
description: "parking explore"
explore: parking_table {
view_name: parking_table
from: parking_table
label: "parking_table explore"
description: "parking_table explore"

join: parkings {
from: parkings
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => parking.data:parkings) parkings;;
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => parking_table.data_column:parkings) parkings;;
relationship: one_to_many
}

join: cars {
from: cars
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => parkings.VALUE:cars) cars;;
relationship: one_to_many
required_joins: [parkings]
}

join: damages {
from: damages
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => cars.VALUE:damages) damages;;
Expand Down
100 changes: 50 additions & 50 deletions examples/cars_on_parking/parking.view
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@

view: parking {
sql_table_name: parking ;;
view: parking_table {
sql_table_name: parking_table ;;

dimension: data_data_generation_timestamp {
description: "Data Data Generation Timestamp"
type: date_time
sql: ${TABLE}.data:dataGenerationTimestamp::string ;;
dimension: data_column_payload_primary_key_value {
description: "Data column Payload Primary Key Value"
type: string
sql: ${TABLE}.data_column:payloadPrimaryKeyValue::string ;;
}

dimension: data_api_version {
description: "Data Api Version"
dimension: data_column_data_provider {
description: "Data column Data Provider"
type: string
sql: ${TABLE}.data:apiVersion::string ;;
sql: ${TABLE}.data_column:dataProvider::string ;;
}

dimension: data_data_provider {
description: "Data Data Provider"
type: string
sql: ${TABLE}.data:dataProvider::string ;;
dimension: data_column_data_generation_timestamp {
description: "Data column Data Generation Timestamp"
type: date_time
sql: ${TABLE}.data_column:dataGenerationTimestamp::string ;;
}

dimension: data_payload_primary_key_value {
description: "Data Payload Primary Key Value"
dimension: data_column_api_version {
description: "Data column Api Version"
type: string
sql: ${TABLE}.data:payloadPrimaryKeyValue::string ;;
sql: ${TABLE}.data_column:apiVersion::string ;;
}

}
Expand All @@ -36,28 +36,10 @@ view: parkings {
sql: ${TABLE}.VALUE:price::number ;;
}

dimension: status_cars_now {
description: "Status Cars Now"
type: number
sql: ${TABLE}.VALUE:status:carsNow::number ;;
}

dimension: price_currency {
description: "Price Currency"
type: string
sql: ${TABLE}.VALUE:priceCurrency::string ;;
}

dimension: price_unit {
description: "Price Unit"
dimension: owner {
description: "Owner"
type: string
sql: ${TABLE}.VALUE:priceUnit::string ;;
}

dimension: status_is_opened {
description: "Status Is Opened"
type: yesno
sql: ${TABLE}.VALUE:status:isOpened::boolean ;;
sql: ${TABLE}.VALUE:owner::string ;;
}

dimension: status_is_broken {
Expand All @@ -66,16 +48,34 @@ view: parkings {
sql: ${TABLE}.VALUE:status:isBroken::boolean ;;
}

dimension: capacity {
description: "Capacity"
type: number
sql: ${TABLE}.VALUE:capacity::number ;;
}

dimension: name {
description: "Name"
type: string
sql: ${TABLE}.VALUE:name::string ;;
}

dimension: capacity {
description: "Capacity"
dimension: status_cars_now {
description: "Status Cars Now"
type: number
sql: ${TABLE}.VALUE:capacity::number ;;
sql: ${TABLE}.VALUE:status:carsNow::number ;;
}

dimension: price_currency {
description: "Price Currency"
type: string
sql: ${TABLE}.VALUE:priceCurrency::string ;;
}

dimension: price_unit {
description: "Price Unit"
type: string
sql: ${TABLE}.VALUE:priceUnit::string ;;
}

dimension: id {
Expand All @@ -84,10 +84,10 @@ view: parkings {
sql: ${TABLE}.VALUE:id::number ;;
}

dimension: owner {
description: "Owner"
type: string
sql: ${TABLE}.VALUE:owner::string ;;
dimension: status_is_opened {
description: "Status Is Opened"
type: yesno
sql: ${TABLE}.VALUE:status:isOpened::boolean ;;
}

}
Expand All @@ -100,18 +100,18 @@ view: cars {
sql: ${TABLE}.VALUE:plate::string ;;
}

dimension: start_time {
description: "Start Time"
type: date_time
sql: ${TABLE}.VALUE:startTime::string ;;
}

dimension: spot {
description: "Spot"
type: number
sql: ${TABLE}.VALUE:spot::number ;;
}

dimension: start_time {
description: "Start Time"
type: date_time
sql: ${TABLE}.VALUE:startTime::string ;;
}

}

view: damages {
Expand Down
3 changes: 2 additions & 1 deletion examples/cars_on_parking/run_generation.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env bash
python ../../main.py --json_files data1.json data2.json --output_view parking.view --output_explore parking.lkml --columnn_name data --sql_table_name parking
source ../../venv/bin/activate
python ../../main.py --json_files data1.json data2.json --output_view parking.view --output_explore parking.lkml --columnn_name data_column --sql_table_name parking_table
27 changes: 7 additions & 20 deletions examples/restaurant_chain/restaurant_chain.lkml
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
include: "restaurant_chain.view"

explore: chains {
view_name: chains
from: chains
label: "chains explore"
description: "chains explore"
explore: chains_table {
view_name: chains_table
from: chains_table
label: "chains_table explore"
description: "chains_table explore"

join: restaurants {
from: restaurants
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => chains.raw_data:restaurants) restaurants;;
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => chains_table.raw_data_column:restaurants) restaurants;;
relationship: one_to_many
}

join: menu {
from: menu
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => restaurants.VALUE:menu) menu;;
relationship: one_to_many
required_joins: [restaurants]
}

join: indegrients {
from: indegrients
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => menu.VALUE:indegrients) indegrients;;
Expand All @@ -28,13 +21,7 @@ explore: chains {

join: floors {
from: floors
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => chains.raw_data:headquater:building:floors) floors;;
relationship: one_to_many
}

join: chains_restaurants {
from: chains_restaurants
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => chains.raw_data:restaurants) chains_restaurants;;
sql:,LATERAL FLATTEN(OUTER => TRUE, INPUT => chains_table.raw_data_column:headquater:building:floors) floors;;
relationship: one_to_many
}

Expand Down
Loading

0 comments on commit 4d626e2

Please sign in to comment.