hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amal Gupta <Amal.Gup...@aexp.com>
Subject RE: Executing HQL files from JAVA application.
Date Sat, 21 Mar 2015 12:42:57 GMT
Thanks lot Steve for your time and response.

I did try that out and was able to execute the basic select statements. But the concern I
had is that the queries contained in the hql files are complicated queries with joins, grouping
etc and they also do some insert operations. Essentially, I was a bit skeptical about doing
their execution in the java app as I would just be bringing the computation logic to my application.
 Furthermore there would be multiple such scripts running in parallel from the same Java app.

Regards,
Amal

From: Steve Howard [mailto:stevedhoward@gmail.com]
Sent: Saturday, March 21, 2015 3:03 PM
To: user@hive.apache.org
Subject: Re: Executing HQL files from JAVA application.

There are more elegant ways I am sure, but you could also use a java.io.BufferedReader and
read the file content into a string and execute it much as you would a hard coded SQL statement
in your class.

Sent from my iPad

On Mar 21, 2015, at 5:04 AM, Amal Gupta <Amal.Gupta1@aexp.com<mailto:Amal.Gupta1@aexp.com>>
wrote:
Hi Everyone,

I am trying to execute a hive *.hql file from a java application.  I had tried a couple of
ways of doing it through JDBC driver for hive and through spring jdbc template but yet, the
only way which was successful for me was to create a runtime process and then execute it.

The java code to do that is

Process p = Runtime.getRuntime().exec((new String[]{"hive","-f","/hive/scripts/demoHiveTable.hql"}));

Although this works but, I wanted to know if there is better way to do it using some driver
functionality or any other api for hive. The method I used will do the execution for me, but
yet, in case of failures while executing the hql script, the same will not be visible to the
Java application.

Any pointers or suggestions will be greatly helpful. Thanks in advance.

Please let me know in case you need any other details from me.

Regards,
Amal
________________________________
American Express made the following annotations
________________________________

"This message and any attachments are solely for the intended recipient and may contain confidential
or privileged information. If you are not the intended recipient, any disclosure, copying,
use, or distribution of the information included in this message and any attachments is prohibited.
If you have received this communication in error, please notify us by reply e-mail and immediately
and permanently delete this message and any attachments. Thank you."

American Express a ajouté le commentaire suivant le
Ce courrier et toute pièce jointe qu'il contient sont réservés au seul destinataire indiqué
et peuvent renfermer des renseignements confidentiels et privilégiés. Si vous n'êtes pas
le destinataire prévu, toute divulgation, duplication, utilisation ou distribution du courrier
ou de toute pièce jointe est interdite. Si vous avez reçu cette communication par erreur,
veuillez nous en aviser par courrier et détruire immédiatement le courrier et les pièces
jointes. Merci.
________________________________


American Express made the following annotations
******************************************************************************
"This message and any attachments are solely for the intended recipient and may contain confidential
or privileged information. If you are not the intended recipient, any disclosure, copying,
use, or distribution of the information included in this message and any attachments is prohibited.
If you have received this communication in error, please notify us by reply e-mail and immediately
and permanently delete this message and any attachments. Thank you."

American Express a ajouté le commentaire suivant le Ce courrier et toute pièce jointe qu'il
contient sont réservés au seul destinataire indiqué et peuvent renfermer des 
renseignements confidentiels et privilégiés. Si vous n'êtes pas le destinataire prévu,
toute divulgation, duplication, utilisation ou distribution du courrier ou de toute pièce
jointe est interdite. Si vous avez reçu cette communication par erreur, veuillez nous en
aviser par courrier et détruire immédiatement le courrier et les pièces jointes. Merci.

******************************************************************************
Mime
View raw message