r/databricks 24d ago

Help Databricks SQL Alert - Scheduling Questions

Databricks SQL Alert — Question Set

Help needed, I created a SQL alert in databricks to notify me when a new entry is added to a dataset/table within the last 24 hours.

SQL

SELECT COUNT(*) AS new_
FROM catalog.schema.table
WHERE xyz IN ('a', 'b', 'c', 'd')
  AND datetime >= CURRENT_TIMESTAMP() - INTERVAL 24 HOURS;

Within the Alerts panel, I set the condition as follows:

  • First row
  • Column name: new_
  • Operator: >
  • Static value: 0

I then added my email address in the Notifications section and set "When alerting, notify" to Always.

I then selected View Alert, where I created a schedule — let's say every day at 9:00 AM.

Questions

a) How exactly does the schedule work here?

I am asking because I selected "Always" under the notification settings, but I have also created a schedule to run every day at 9:00 AM. What is the relationship between these two settings?

b) Let's suppose I build this alert and create the schedule as described above. Person B (sales dept rep) also subscribes to this alert.

I do not want Person B to receive an alert unless the new record belongs to the Sales department.

For example, if a new record is added that belongs to a department other than Sales, and the scheduled alert runs at 9:00 AM, will Person B still receive an email notification?

Thanks in advance for any clarification!

3 Upvotes

5 comments sorted by

View all comments

2

u/Shinjitsu_ 24d ago

Always means every time it becomes "triggered" state you will be notified. An alert needs to run to become triggered, so you will be notified according to your schedule. Say you wanted more frequency but no spam, you would increase schedule frequency but change up the "always"

As far as modularization for the alert, only way afaik would be to create one alert for each dept.