fix comments

This commit is contained in:
dr0zd
2026-01-31 03:29:26 +07:00
parent eca39dbcee
commit 0433c72828
7 changed files with 16 additions and 32 deletions
+4 -4
View File
@@ -8,11 +8,11 @@
select
user_id,
toDecimal64OrNull(balance, 2) as balance,
toTimeDate64OrNull(created_at, 3) as created_at
toDateTime64OrNull(created_at, 3) as created_at
from raw_data
where
toDecimal64OrNull(balance, 2) is not null and
toTimeDate64OrNull(created_at, 3) is not null
toDateTime64OrNull(created_at, 3) is not null
-- task 2 (failed)
CREATE TABLE events (
@@ -23,7 +23,7 @@
select
event_id,
toStartOfHour(toDateTimeOrNull(concatWithSeparator(' ', events_date, events_time)))
toStartOfHour(toDateTimeOrNull(concatWithSeparator(' ', event_date, event_time)))
from events
where
toDateOrNull(event_date) is not null and toTimeOrNull(event_time) is not null
@@ -57,5 +57,5 @@
avg(value) as avg_value
from sensor_data
where
toDecimal64OrNull(value, 2) is not null
value is not null
group by status
+2 -2
View File
@@ -65,7 +65,7 @@
'/clickhouse/tables/{shard}/mdrozdov/orders',
'{replica}'
)
order by size
order by (symbol, time)
insert into mdrozdov.orders values
('2025-07-17 10:00:30', 'AAPL', 50),
@@ -97,7 +97,7 @@
bl.user_id,
u.name,
bl.event_time,
bl.event_type,
bl.event_type
from big_logs bl
any left join users u
using(user_id)
+1 -1
View File
@@ -18,7 +18,7 @@
Order by id;
-- region_sales table
create table region_sales(
create table mdrozdov.region_sales(
region String,
date Date,
sales UInt64
+3 -3
View File
@@ -1,4 +1,4 @@
CREATE TABLE users (
CREATE TABLE mdrozdov.users (
user_id Int,
name String,
age Int,
@@ -113,10 +113,10 @@ CREATE TABLE users (
from mdrozdov.events
--3) да, поддерживается, но не обязательно для коммулятивного суммирования строк
--4-6) Сделай WITH recent_events AS (...) — все события за последние 24 часа.
with recent_events AS (
with mdrozdov.recent_events AS (
select *
from mdrozdov.events
where event_time >= '2025-07-18'::DATE - interval '1 day'
where event_time >= toDateTime('2025-07-18') - interval 1 day
), category_list as (
select 'click' as event_type, 'interaction' as category
union all
+3 -3
View File
@@ -40,7 +40,7 @@ engine = ReplicatedMergeTree(
order by id
alter table mdrozdov.clicks
add index idx_country type set(100) GRANULARITY 2
add index idx_country country type set(100) GRANULARITY 2
Explain
select *
@@ -59,7 +59,7 @@ engine = ReplicatedMergeTree(
)
order by id
ALTER TABLE users
ALTER TABLE mdrozdov.users
ADD INDEX idx_email email TYPE bloom_filter(0.01) GRANULARITY 2;
SELECT * FROM users WHERE email = 'alice@mail.com';
SELECT * FROM mdrozdov.users WHERE email = 'alice@mail.com';
+2 -1
View File
@@ -23,6 +23,7 @@
--task 3
CREATE MATERIALIZED VIEW
to
ENGINE = SummingMergeTree
order by date
mv_clicks_per_day AS
@@ -30,4 +31,4 @@
toDate(event_time) as date,
count(*) as total_clicks
from raw_events
group date
group by date
+1 -18
View File
@@ -76,14 +76,6 @@
course_id::INT
FROM raw.lessons;
INSERT INTO core.dim_lesson (lesson_id, title, duration_min, course_id)
SELECT DISTINCT
id::INT,
title::TEXT,
duration_min::INT,
course_id::INT
FROM raw.lessons;
-- Заполнение таблицы фактов
insert into core.fact_lesson_views (user_id, lesson_id, course_id, viewed_at)
select
@@ -94,16 +86,7 @@
from raw.lessons_views lw
join raw.lessons l on lw.lesson_id = l.id;
insert into core.enrollments (user_id, lesson_id, course_id, viewed_at)
select
lw.user_id,
lw.lesson_id,
l.course_id,
lw.viewed_at
from raw.lessons_views lw
join raw.lessons l on lw.lesson_id = l.id;
insert into enrollments (user_id, course_id, enrolled_at)
insert into core.enrollments (user_id, course_id, enrolled_at)
select
user_id,
course_id,