Running Multiple Hive Queries In one session

Follow / 3 Jan 2012 at 11:29pm

Hi,
  I am connecting to the Hive Server using TCD eclipse plugin and running HIVE QL commands. One question that i had was how do i run multiple queries in one session? What im trying to do is run commands like:

add jar jarname;
create temporary function blah;
select blah(field) from table where date=date;

The above two commands and the select have to run before the third select runs, else the select will fail. Basically all the three commands have to run in one session.

How can i do that?

Replies

  • Follow / 6 Jan 2012 at 1:52am
    Hi Amit,

    I've been looking at this issue, and sadly I only have a couple of points to make, and no workaround for the current production version.

    Unfortunately the direct Hive connection does not allow multiple statements and returns a syntax error on the semi-colon. We will need to break up the statements and executed them individually to resolve the issue.

    We are preparing TCD release 1.6 at the moment and this will be available very soon. This version includes provision for specifying one or more JAR files with which to initialise the Hive connection. These are specified in the connection dialog and automatically loaded each time a connection is made.

    This mechanism was intended for loading SerDE JARS, but we could extend it to allow any valid Hive statement as a means to initialise each connection. This would allow you to add your JARs and map their functions to Hive, but it would do it every time you made a connection.

    We would also like to prototype some of these ideas and give you a link to a development version of TCD when the problem has been resolved. Could you please send an email to toad.cloud.support@quest.com so that we can send you a link when we create the update site?

    Thanks,
    Greg.
  • Follow / 6 Jan 2012 at 9:07pm

    Hi Greg,
       Thanks for the response. Is this issue only for Hive Connection? What about when i use a HUB? Can we run commands in a session there?

    On a different note what is the time line of the release of version 1.6? I was told that the next version of TCD will be hive database/schema aware. Is that feature in 1.6?

    I will send an email to the address mentioned by you to get the development link. We have huge demand for setting up TCD at Netflix and i would love try out the prototypes. Although the lack of support for Hive Databases, is a blocker for us.

    Thanks,
    Amit

  • Follow / 9 Jan 2012 at 10:21pm
    Marking it unanswered so that it gets attention.
  • Follow / 10 Jan 2012 at 3:29am

    Hi Amit,

    Unfortunately the same issue will occur for a Hive connection using the Hub.  The development build should get you unblocked and also provide us with some valuable feedback.

    The 1.6 release has been delayed.  I would expect it to be released in the later part of February.   Hive in 1.6 will be database/schema aware. Again this feature is already in the development build.

    Regards,
    Stewart.

  • Follow / 5 May 2013 at 7:21pm

    Hi,

    Was this issue ever solved? I saw the last communication on this thread was well over a year ago. I am still facing the same issue described in this post when I'm using Toad for Cloud eclipse plugin.. I can't seem to run a hive "script" using toad for cloud, connecting to EMR/Hive. It runs only one hive statement at a time (to clarify, not one line, but one hive statement - even if it is broken into multiple lines). this is very cumbersome when you have a bunch of settings etc for your query and you have to execute each and every single hive query one by one..

    Regards,
    Lakshmi Naarayanan R

  • Follow / 13 May 2013 at 3:55pm

    As Greg mentioned, a possible workaround is to use the Hive initialization statements property of the connection. Here you can add multiple valid Hive statements (intended for use as a means to initialise each connection), but note that these will all be executed each time you make a connection.

    Does this help you?

    Thanks,

    Lee