I have a Materialized View that joins with tables replicated from PostgreSQL:
(database with replicated tables)
CREATE DATABASE postgres_tables
ENGINE = MaterializedPostgreSQL('DB_HOST:DB_PORT', 'DB_NAME', 'DB_USER', 'DB_PASS')
SETTINGS materialized_postgresql_tables_list = 'note_time_logs,notes'
(materialized view)
CREATE MATERIALIZED VIEW my_db.note_time_logs__mv
TO my_db.time_logs
AS SELECT
ntl.person_id as person_id,
toDate(ntl.created_at) as date,
n.tag as tag,
ntl.service_id as service_id,
sum(CAST(CEIL(COALESCE(ntl.duration, 0)), 'UInt16')) as total_minutes
FROM postgres_tables.note_time_logs ntl
LEFT JOIN postgres_tables.notes n ON n.id = ntl.note_id
GROUP BY person_id, date, service_id, tag
The records generated by the MV are missing values from the joined table (tag
, in this case). It looks like the data of that table is taking a bit longer to be replicated and, when the MV does the JOIN, the data is not there yet.
Is there a way to handle this case?