Skip to content

Commit

Permalink
Merge pull request #15 from isankadn/dev
Browse files Browse the repository at this point in the history
na
  • Loading branch information
isankadn authored Mar 24, 2024
2 parents 89faecf + 47a8e5e commit baa8293
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions historical_data/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,15 @@ async fn deduplicate_clickhouse_data(
};

let create_dedup_table_query = format!(
"CREATE TABLE {table}_dedup AS
"CREATE TABLE {table}_dedup
ENGINE = MergeTree()
PARTITION BY toYYYYMM(created_at)
PRIMARY KEY id
ORDER BY (id, created_at)
SETTINGS index_granularity = 8192
AS
SELECT * FROM (
SELECT *, row_number() OVER (PARTITION BY id ORDER BY id) AS row_num
SELECT *, row_number() OVER (PARTITION BY id ORDER BY created_at) AS row_num
FROM {table}
)
WHERE row_num = 1;",
Expand Down

0 comments on commit baa8293

Please sign in to comment.