Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clickhouse): Rework tables configuration #2657

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions app/models/clickhouse/events_enriched.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class EventsEnriched < BaseRecord
#
# Table name: events_enriched
#
# aggregation_type :string
# code :string not null
# filters :string not null
# grouped_by :string not null
# properties :string not null
# timestamp :datetime not null
# value :string
# charge_id :string not null
# external_subscription_id :string not null
# organization_id :string not null
# transaction_id :string not null
# code :string not null
# decimal_value :decimal(26, )
# enriched_at :datetime not null
# precise_total_amount_cents :decimal(40, 15)
# properties :string not null
# sorted_properties :string not null
# timestamp :datetime not null
# value :string
# external_subscription_id :string not null
# organization_id :string not null
# transaction_id :string not null
#
2 changes: 1 addition & 1 deletion app/services/events/create_batch_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def produce_kafka_event(event)
code: event.code,
properties: event.properties,
ingested_at: Time.zone.now.iso8601[...-1],
precise_total_amount_cents: event.precise_total_amount_cents
precise_total_amount_cents: event.precise_total_amount_cents || 0.0
}.to_json
)
end
Expand Down
6 changes: 4 additions & 2 deletions app/services/events/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ def produce_kafka_event(event)
external_customer_id: event.external_customer_id,
external_subscription_id: event.external_subscription_id,
transaction_id: event.transaction_id,
timestamp: event.timestamp.iso8601[...-1], # NOTE: Removes trailing 'Z' to allow clickhouse parsing
# NOTE: Removes trailing 'Z' to allow clickhouse parsing
timestamp: event.timestamp.iso8601[...-1],
code: event.code,
precise_total_amount_cents: event.precise_total_amount_cents,
# NOTE: Default value to 0.0 is required for clickhouse parsing
precise_total_amount_cents: event.precise_total_amount_cents || 0.0,
properties: event.properties,
ingested_at: Time.zone.now.iso8601[...-1]
}.to_json
Expand Down
151 changes: 0 additions & 151 deletions app/services/events/stores/clickhouse/pre_aggregated/base.rb

This file was deleted.

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions app/services/events/stores/clickhouse/pre_aggregated/max_query.rb

This file was deleted.

29 changes: 0 additions & 29 deletions app/services/events/stores/clickhouse/pre_aggregated/sum_query.rb

This file was deleted.

1 change: 1 addition & 0 deletions db/clickhouse_migrate/20231024084411_create_events_raw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def change
t.datetime :timestamp, null: false, precision: 3
t.string :code, null: false
t.string :properties, map: true, null: false
t.decimal :precise_total_amount_cents, precision: 40, scale: 15
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def change
t.string :timestamp, null: false
t.string :code, null: false
t.string :properties, null: false
t.decimal :precise_total_amount_cents, precision: 40, scale: 15
end
end
end
3 changes: 2 additions & 1 deletion db/clickhouse_migrate/20231030163703_create_events_raw_mv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def change
transaction_id,
toDateTime64(timestamp, 3) as timestamp,
code,
JSONExtract(properties, 'Map(String, String)') as properties
JSONExtract(properties, 'Map(String, String)') as properties,
precise_total_amount_cents
FROM events_raw_queue
SQL

Expand Down
Loading