analytics/priv/data_migrations/PopulateEventSessionColumns/sql/update-table.sql.eex
Karl-Aksel Puulmann 26d41ddbb9
Mutation to populate event session columns (#3844)
* WIP mutation to populate event session columns

* Remove duplication

* report errors, allow_nondeterministic_updates

* use right columns

* Update existing columns instead of session_* ones

* Make dialyzer happy

* Fix issue with passing pre-existing params in

* Logger -> IO.puts

* Use IngestRepo.config for connection settings

* Make dictionary options configurable

* Move allow_nondeterministic_mutations to within the migration

* Solve credo warning about too deep nesting

* Missed logger call

* Pattern matching in function head
2024-03-08 09:27:24 +02:00

22 lines
1.5 KiB
Elixir

ALTER TABLE events_v2
<%= if @cluster? do %>ON CLUSTER '{cluster}'<% end %>
UPDATE
referrer = dictGet('sessions_dict', 'referrer', tuple(site_id, session_id)),
referrer_source = dictGet('sessions_dict', 'referrer_source', tuple(site_id, session_id)),
utm_medium = dictGet('sessions_dict', 'utm_medium', tuple(site_id, session_id)),
utm_source = dictGet('sessions_dict', 'utm_source', tuple(site_id, session_id)),
utm_campaign = dictGet('sessions_dict', 'utm_campaign', tuple(site_id, session_id)),
utm_content = dictGet('sessions_dict', 'utm_content', tuple(site_id, session_id)),
utm_term = dictGet('sessions_dict', 'utm_term', tuple(site_id, session_id)),
country_code = dictGet('sessions_dict', 'country_code', tuple(site_id, session_id)),
subdivision1_code = dictGet('sessions_dict', 'subdivision1_code', tuple(site_id, session_id)),
subdivision2_code = dictGet('sessions_dict', 'subdivision2_code', tuple(site_id, session_id)),
city_geoname_id = dictGet('sessions_dict', 'city_geoname_id', tuple(site_id, session_id)),
screen_size = dictGet('sessions_dict', 'screen_size', tuple(site_id, session_id)),
operating_system = dictGet('sessions_dict', 'operating_system', tuple(site_id, session_id)),
operating_system_version = dictGet('sessions_dict', 'operating_system_version', tuple(site_id, session_id)),
browser = dictGet('sessions_dict', 'browser', tuple(site_id, session_id)),
browser_version = dictGet('sessions_dict', 'browser_version', tuple(site_id, session_id))
IN PARTITION '<%= @partition %>'
WHERE 1=1