This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with stock as ( | |
| select id, symbol, date, to_json(data) as data_json from input_stage.stock | |
| ), | |
| final as ( | |
| select | |
| id, | |
| symbol, | |
| date, | |
| CAST(json_extract_path_text(data_json, '1. open') as float) as open, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT RUNAVG({fact/close}) ROWS BETWEEN 20 PRECEDING AND CURRENT ROW |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| predictions = predict_model(best, data=report_data) | |
| print(predictions.head()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - name: revenue | |
| label: Revenue | |
| model: ref('revenue_all') | |
| calculation_method: sum | |
| expression: price * quantity | |
| timestamp: date | |
| time_grains: [day, week, month, quarter, year] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with customer_group as ( | |
| SELECT customer_id, sum(revenue) AS revenue_sum | |
| FROM {{ metrics.calculate( | |
| metric('revenue'), | |
| grain='day', | |
| dimensions=['customer_id'] | |
| ) }} | |
| GROUP BY customer_id | |
| ), | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT (SUM({fact/price} * {fact/quantity})) WHERE {label/order_status} = "Delivered" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT {metric/gd_revenue} WHERE TOP(10%) OF ({metric/gd_revenue}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT ( | |
| SELECT {metric/gd_revenue} WHERE ( | |
| SELECT {metric/revenue_top_10} BY {label/customers.customer_id} ALL OTHER | |
| ) > 0 | |
| ) / {metric/gd_revenue} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run extract and load | |
| on: | |
| push: | |
| schedule: | |
| - cron: "0 2 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| run_extract_load: | |
| runs-on: ubuntu-latest | |
| steps: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with deals as (select id, created_date, to_json("item") as item_json from input_stage.airtable_crm_deals), | |
| final as ( | |
| select | |
| id, | |
| CAST(json_extract_path_text(item_json, 'Name') as VARCHAR) as name, | |
| CAST(json_extract_path_text(item_json, 'Stage') as VARCHAR) as stage, | |
| CAST(json_extract_path_text(item_json, 'Amount') as NUMERIC) as amount, | |
| CAST(json_extract_path_text(item_json, 'Details') as VARCHAR) as details, | |
| CAST(json_extract_path_text(item_json, 'Close Probability') as NUMERIC) as close_probability, |