<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Cannot Get Query Results in SQL Alerts in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/cannot-get-query-results-in-sql-alerts/m-p/96749#M39337</link>
    <description>&lt;P&gt;Example Query:&lt;/P&gt;&lt;P&gt;select name, date from errors;&lt;/P&gt;&lt;P&gt;Now i want to trigger an alert if count is greater than 1, and a notification should be sent to slack with output rows (name and date values). Even if i use {{QUERY_RESULT_ROWS}}, it only gives value after count is applied.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to get the actual rows using Alerts?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2024 05:25:37 GMT</pubDate>
    <dc:creator>AcrobaticMonkey</dc:creator>
    <dc:date>2024-10-30T05:25:37Z</dc:date>
    <item>
      <title>Cannot Get Query Results in SQL Alerts</title>
      <link>https://community.databricks.com/t5/data-engineering/cannot-get-query-results-in-sql-alerts/m-p/96749#M39337</link>
      <description>&lt;P&gt;Example Query:&lt;/P&gt;&lt;P&gt;select name, date from errors;&lt;/P&gt;&lt;P&gt;Now i want to trigger an alert if count is greater than 1, and a notification should be sent to slack with output rows (name and date values). Even if i use {{QUERY_RESULT_ROWS}}, it only gives value after count is applied.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to get the actual rows using Alerts?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 05:25:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/cannot-get-query-results-in-sql-alerts/m-p/96749#M39337</guid>
      <dc:creator>AcrobaticMonkey</dc:creator>
      <dc:date>2024-10-30T05:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get Query Results in SQL Alerts</title>
      <link>https://community.databricks.com/t5/data-engineering/cannot-get-query-results-in-sql-alerts/m-p/97028#M39399</link>
      <description>&lt;P&gt;Note I have not tried this myself, but can you try the following and let me know if it helps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create the query, so&amp;nbsp;&lt;STRONG&gt;SELECT name, date FROM errors;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Set up the alert. Set the condition to trigger the alert when the count of rows is greater than 1.&lt;/LI&gt;
&lt;LI&gt;Create a separate query that formats the result as a single string.
&lt;OL&gt;
&lt;LI&gt;&lt;LI-CODE lang="markup"&gt;SELECT CONCAT_WS(', ', COLLECT_LIST(CONCAT(name, ' - ', date))) AS formatted_result
FROM errors
WHERE &amp;lt;your_condition&amp;gt;;&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Use this query in your alert to trigger the notification. The formatted_result should contain the concatenated rows.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Send notification to Slack. In the alert settings, you can use the formatted_result to include the actual rows in the message.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 31 Oct 2024 16:34:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/cannot-get-query-results-in-sql-alerts/m-p/97028#M39399</guid>
      <dc:creator>VZLA</dc:creator>
      <dc:date>2024-10-31T16:34:58Z</dc:date>
    </item>
  </channel>
</rss>

