From c002621d8bd7d04daeef9514a0b58f6ad8ba6187 Mon Sep 17 00:00:00 2001 From: DmitryBolo Date: Sun, 9 Jun 2024 16:51:36 +0000 Subject: [PATCH] Bolotyuk Dmitry --- .env.template | 2 -- main.tf | 13 ++++++------- models/marts/f_orders_stats.sql | 19 ++++++++++++++++++- package-lock.yml | 4 ++++ 4 files changed, 28 insertions(+), 10 deletions(-) delete mode 100644 .env.template create mode 100644 package-lock.yml diff --git a/.env.template b/.env.template deleted file mode 100644 index d273717..0000000 --- a/.env.template +++ /dev/null @@ -1,2 +0,0 @@ -CLICKHOUSE_USER=admin -TF_VAR_clickhouse_password=clickhouse \ No newline at end of file diff --git a/main.tf b/main.tf index d20e1a9..2fd64a6 100644 --- a/main.tf +++ b/main.tf @@ -18,7 +18,7 @@ resource "yandex_mdb_clickhouse_cluster" "clickhouse_starschema" { sql_database_management = true sql_user_management = true admin_password = var.clickhouse_password - version = "23.3" + version = "23.8" clickhouse { resources { @@ -39,21 +39,20 @@ resource "yandex_mdb_clickhouse_cluster" "clickhouse_starschema" { timezone = "UTC" geobase_uri = "" query_log_retention_size = 1073741824 - query_log_retention_time = 2592000 query_thread_log_enabled = true query_thread_log_retention_size = 536870912 - query_thread_log_retention_time = 2592000 + part_log_retention_size = 536870912 - part_log_retention_time = 2592000 + metric_log_enabled = true metric_log_retention_size = 536870912 - metric_log_retention_time = 2592000 + trace_log_enabled = true trace_log_retention_size = 536870912 - trace_log_retention_time = 2592000 + text_log_enabled = true text_log_retention_size = 536870912 - text_log_retention_time = 2592000 + text_log_level = "TRACE" background_pool_size = 16 background_schedule_pool_size = 16 diff --git a/models/marts/f_orders_stats.sql b/models/marts/f_orders_stats.sql index f3c422a..fcf153e 100644 --- a/models/marts/f_orders_stats.sql +++ b/models/marts/f_orders_stats.sql @@ -5,4 +5,21 @@ ) }} -SELECT 1 +SELECT + toYear(O_ORDERDATE) AS O_ORDERYEAR + , O_ORDERSTATUS + , O_ORDERPRIORITY + , count(DISTINCT O_ORDERKEY) AS num_orders + , count(DISTINCT C_CUSTKEY) AS num_customers + , sum(L_EXTENDEDPRICE * L_DISCOUNT) AS revenue +FROM {{ ref('stg_lineitem') }} AS l + INNER JOIN {{ ref('stg_orders') }} AS o ON o.O_ORDERKEY = l.L_ORDERKEY + INNER JOIN {{ ref('stg_customer') }} AS c ON c.C_CUSTKEY = o.O_CUSTKEY + INNER JOIN {{ ref('stg_supplier') }} AS s ON s.S_SUPPKEY = l.L_SUPPKEY + INNER JOIN {{ ref('stg_part') }} AS p ON p.P_PARTKEY = l.L_PARTKEY + +WHERE 1=1 +GROUP BY + toYear(O_ORDERDATE) + , O_ORDERSTATUS + , O_ORDERPRIORITY diff --git a/package-lock.yml b/package-lock.yml new file mode 100644 index 0000000..8f949e9 --- /dev/null +++ b/package-lock.yml @@ -0,0 +1,4 @@ +packages: +- package: dbt-labs/dbt_utils + version: 1.0.0 +sha1_hash: f4c10e8eb3db97171ea98d4851377e010cce1478