DLH Logo

DLH.io ๐Ÿ”ฅ - Introducing DW
SQL Queries to Slack with Emoji Support

Ok, why do we need Emojis with our SQL ๐Ÿš€ย ?

We donโ€™t but the question is could we print emojiโ€™s with our data in Snowflake, MotherDuck, and produce report outputs that give color to the drab data by highlighting that information through Slack for daily reporting, etc?

Real analytics ๐Ÿ“Š engineers know that requests for information come in many shapes and forms โœจ. Sometimes it is our curiosity ๐Ÿ‘€ that makes us solve problems and stand out by delivering something with a bit more polish ๐Ÿ”ฎ.

Or, perhaps we want to do something with conveying data as something that someone didnโ€™t think was possible ๐Ÿ’ก. We think this article highlights one of those stand-out concepts that if you know, then you just know ๐Ÿ™‹โ€โ™‚๏ธ. And, instead of writing Python scripts or another ungoverned notebook file, then you know you can use a managed solution such as DLH.io ๐Ÿ… to help you send data to your favorite destinations with no-code in a matter of minutes.

FYI, we snagged emoji icons like the ones used in this article ๐Ÿ”ฅ from https://emojipedia.org.

Weโ€™ve found that most major data lakehouse/warehouse ๐Ÿ”‘ vendors in the new modern data + AI era/stack support this cute ๐Ÿซ  emoji take on amplifying boring report outputs.

Itโ€™s easy ๐Ÿ˜Š not painful ๐Ÿ˜ญโ€Šโ€”โ€ŠSo how does it work? How can we create a managed output to one of our enterprise IM channels like thisโ€ฆ

Image

In DLH, this works in both Microsoft Teams and in Slack. So follow these same instructions for Teams and youโ€™ll be just peachy ๐Ÿ‘.

Here are the steps you can follow to easily set this up in DLH:

Connect to data source

Create a source connection to one of your databases, data warehouse systems or even NetSuite.

Image

DLH supports the SQL Query function directly against NetSuite but also other main data warehouse systems such as Databricks, MotherDuck, and Snowflake.

Image


Connect to your slack as a target

This would be the same for Microsoft Teams; just connect seamlessly with your enterprise IM system as a target destination.

Image

You can modify the channel in the Target Options tab, and also create the main message for this Slack message there as well.

Image

Create a SQL Query with a specific single row return

This is a query supported by your source system and placed into this special source connection type. Select your data source connector created from the first step by name.

Image

The example here is one of a simple aggregate row of metrics that provide a daily deliverable of key performance indicators to business users.

Update column names to reflect emoji syntax (be sure to add double quotes or the systemโ€™s column identifier syntax around column names).

In the SQL, you can see that you can use HTML emoji codes or the emoji itself by copying and pasting it into the appropriate SQL column.

sql
SELECT
TO_CHAR(CREATED, 'YYYY-MM-DD') AS "(?) Purchase Date",
BILLING_REASON AS "(:large_green_circle:) Billing Reason",
SUM(AMOUNT_DUE) AS "(:heavy_dollar_sign:) Amount",
SUM(AMOUNT_PAID) AS "(U+1F4B8) Amount Paid X",
SUM(AMOUNT_PAID) AS "(:money_bag:) Amount Paid Y",
TO_VARCHAR(SUM(AMOUNT_PAID), '$999,999,999.00') AS "(๐Ÿ’ฐ) Amount Paid Z"
FROM
DEMO_DB.STRIPE_TARGET_TEST_STRIPE.INVOICE
WHERE
AMOUNT_DUE > 0
AND
TO_CHAR(CREATED, 'YYYY-MM-DD') = '2020-10-02'
GROUP BY
TO_CHAR(CREATED, 'YYYY-MM-DD'),
BILLING_REASON
ORDER BY
1
;

Create your Sync Bridge

A sync bridge is a pipeline or an orchestration step that says, โ€œconnect my source to my target.โ€

In the Sync Bridge, give it a name and select your source from the first step and your target from the second step. Then choose a frequency and any notification setting overrides.

Click save; your sync bridge is ready to run now manually or on the first scheduled run.

Image

Could this be done in Python? Sure, but why would your data team do that when there is a managed ELT and Orchestration system with better logging, connectivity, and so many other great features for your team to use?

And, this way you donโ€™t have to manage code in a notebook or script, which turns your team into a software development team instead of a crack internal data engineering team that provides fast business solutions on governed data.

Running the DLH sync bridge gets you a message that looks like the following Slack message in your channel:

Image

From a data warehouse perspective, for example on Snowflake, here is what a query looks like from the UI.

And notice the resulting dataset with the most important part, the column headers:

Image

Notice how the different ways of providing icons or HTML code icons do not come through for column structuring. This same delta happens with Slack as well using programmatic methods.

So the resulting rule or knowledge learned here is that to produce consistent emoji results, you can use emoji icons themselves, which need to be copied and pasted directly from the source of the icon from a browser into the text of the SQL code itself. You can get away with certain basic emoji tags known to Slack and Teams, for example (:calendar:), but for an exhaustive list or capability, using the copied images will deliver more consistent results.

Letโ€™s now replace our DLH SQL Query with only emoji icons. Notice we are using here a Snowflake function TO_VARCHAR(x, y) to format the amount to dollars for the last column just to show how a value stored as a decimal/number can be converted for this type of output reporting query.

sql
SELECT
TO_CHAR(CREATED, 'YYYY-MM-DD') AS "(๐Ÿ—“) Purchase Date",
BILLING_REASON AS "(๐Ÿ™‹โ€โ™‚๏ธ) Billing Reason",
SUM(AMOUNT_DUE) AS "(๐Ÿ’ฒ) Amount",
SUM(AMOUNT_PAID) AS "(๐Ÿค‘) Amount Paid X",
SUM(AMOUNT_PAID) AS "(๐Ÿ”ฎ) Amount Paid Y",
TO_VARCHAR(SUM(AMOUNT_PAID), '$999,999,999.00') AS "(๐Ÿ’ฐ) Amount Paid Z"
FROM
DEMO_DB.STRIPE_TARGET_TEST_STRIPE.INVOICE
WHERE
AMOUNT_DUE > 0
AND
TO_CHAR(CREATED, 'YYYY-MM-DD') = '2020-10-02'
GROUP BY
TO_CHAR(CREATED, 'YYYY-MM-DD'),
BILLING_REASON
ORDER BY
1
;

Now letโ€™s run our sync bridge to see our Slack message output.

Image

Get your free starter company account at DLH.io and try it for yourself.