简体   繁体   中英

Sending an email from HIVE when a query is completed?

I am new to HIVE and have been unable to find an answer that helps without the use of add-ons or 3rd party stuff that adds to HIVE, which I can not use.

I currently have a few collegues in another location who run queries to update tables that are used during my day for some reporting. I am trying to understand if there is something I can have them add to their SQL in HIVE that just sends an email to me, when the query is completed. I do not need it to have any attachments or anything. Just simply let me know that the tables have been updated.

No, there is nothing in the HiveQL that will send an email.

A simple BASH script could accomplish what you're after.

#!/usr/bin/env bash
beeline -u jdbc:hive2://NameNode:10000/my_db -q "SELECT col1, col2,col3 from db.table"
if [[ $? = 0]];then
    mail -s "Query Completed" me@example.com <<< 'Your query completed.'
else
    mail -s "Query Error" me@example.com <<< 'Something went wrong.'
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM