Skip to content
Advertisement

Find missing entries by date

I have two redshift tables:

  • alert_type: where i keep types of alerts in my system
  • alert: where i keep alerts

Every day I generate a new alert for each alert type. If something has failed in application side I will be missing an entry in alert table. So I’m trying to write a query to get alert_type‘s that are missing and date for which they are missing.

Since there is an issue with generate_series running only on leader node I’m using this query to generate last 30 dates.

The following query returns all dates that are missing but I don’t get the alerts.alert_type_id property from this.

I’m not sure how to turn this query to be able to go from alert_type to alert to basically get: alert_type.name | date_missing

Advertisement

Answer

Generate the dates and alerts and then use left join or not exists to filter out the ones with no match

I simplified a bit the part about generating the dates.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement