You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by abhinav narain <ab...@gmail.com> on 2011/01/20 07:08:59 UTC
The control flow of hive
Hi,
I have two questions to ask,
1.
How does one have access to metastore of Hive, to retrieve the schema
information from it.
I cant find a file or other such thing in source code.
2.
How does one get the handle of the result that is produced after the query.
If someone can tell about where to look for the answers, that will also help
regards,
Abhinav
Re: The control flow of hive
Posted by abhinav narain <ab...@gmail.com>.
hi,
The package names of the files show error, for example :
package org.apache.hadoop.hive.ql.parse;
when the whole src folder of Hive is copied to the src folder of a new
Netbeans project.
I have problems with the following imports :
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.InputFormat;
import org.apache.hadoop.mapred.TextInputFormat;
and similarly more.
I am not sure, If I have to add hadoop jar files in the project as library.
The hadoop and hive are installed in my home folder, while the IDE is
installed in another partition.
Can someone help me by telling me about what should be done about the
package names and the missing imports jars ?
regards,
Abhinav
On Mon, Jan 24, 2011 at 10:44 AM, abhinav narain
<ab...@gmail.com>wrote:
> hi,
> I would like to elaborate on what I wish to do.
>
> I want to store the results of hive query in a database instead of just
> displaying it on the hive shell.
> For this I need to modify/ add code at two places.
> 1. To fetch the schema from metastore, so that i can create a table in
> mySql database
> 2. Get a handle of a cursor, so that i can dump the result into the
> database.
>
> I am unable to figure out how to write my code by implementing an interface
> and create jar file so that I can see the results when I run hive again.
>
> I have imported Hive src folder to eclipse, but I am not sure what should I
> do next.
> Your help would be greatly appreciated.
>
> regards,
> Abhinav Narain
>
>
> On Fri, Jan 21, 2011 at 2:30 PM, abhinav narain <abhinavnarain10@gmail.com
> > wrote:
>
>> Thanks for the prompt replies.
>> I have gone through the code.
>> But i am unable to understand how can I integrate my own class and compile
>> the code in a jar to be executed later.
>> I am undergraduate and have not worked on such big project.
>>
>> Some hints will be very helpful.
>>
>> thanks again for the replies.
>>
>> regards,
>> Abhinav Narain
>>
>> On Thu, Jan 20, 2011 at 1:02 PM, Carl Steinbach <ca...@cloudera.com>wrote:
>>
>>> Hi Abhinav,
>>>
>>> 1.
>>> > How does one have access to metastore of Hive, to retrieve the schema
>>> > information from it.
>>> > I cant find a file or other such thing in source code.
>>> >
>>>
>>> Take a look at the IMetaStoreClient interface and HiveMetaStoreClient
>>> class,
>>> but bear in mind that the fundamental definition of the MetaStore
>>> interface
>>> is contained in the Thrift IDL file located
>>> here: metastore/if/hive_metastore.thrift. IMetaStoreClient actually
>>> defines
>>> a wrapper interface around the code generated by the Thrift compiler
>>> based
>>> on the definitions in hive_metastore.thrift
>>>
>>> You can also find some good code examples in TestHiveMetaStore.
>>>
>>>
>>> > 2.
>>> > How does one get the handle of the result that is produced after the
>>> query.
>>> >
>>> > If someone can tell about where to look for the answers, that will also
>>> > help
>>> >
>>>
>>> Here are the relevant pieces of code that you should look at:
>>>
>>> service/if/hive_service.thrift
>>> service/src/java/org/apache/hadoop/hive/service/HiveServer.java
>>> service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java
>>>
>>> The interface for executing queries and fetching results is defined in
>>> hive_service.thrift and consists of the following methods:
>>>
>>> void execute(string query)
>>> string fetchOne()
>>> list<string> fetchN(i32 numRows)
>>> list<string> fetchAll()
>>>
>>> Since execute() does not return a query ID the Thrift client is limited
>>> to
>>> executing/fetching the results of a single query at a time.
>>>
>>> Hope this helps.
>>>
>>> Carl
>>>
>>
>>
>
Re: The control flow of hive
Posted by Namit Jain <nj...@fb.com>.
Do you want to do it offline - I mean, insert in a hive table - that will
be done parallely
using map-reduce.
This is a jira on export-import for hive being worked on.
It might be simpler to just export the data and import it into another db
table.
It might take some work to get the format compatible. But, this approach
might be simpler to maintain.
On 1/23/11 9:14 PM, "abhinav narain" <ab...@gmail.com> wrote:
>hi,
>I would like to elaborate on what I wish to do.
>
>I want to store the results of hive query in a database instead of just
>displaying it on the hive shell.
>For this I need to modify/ add code at two places.
>1. To fetch the schema from metastore, so that i can create a table in
>mySql
>database
>2. Get a handle of a cursor, so that i can dump the result into the
>database.
>
>I am unable to figure out how to write my code by implementing an
>interface
>and create jar file so that I can see the results when I run hive again.
>
>I have imported Hive src folder to eclipse, but I am not sure what should
>I
>do next.
>Your help would be greatly appreciated.
>
>regards,
>Abhinav Narain
>
>On Fri, Jan 21, 2011 at 2:30 PM, abhinav narain
><ab...@gmail.com>wrote:
>
>> Thanks for the prompt replies.
>> I have gone through the code.
>> But i am unable to understand how can I integrate my own class and
>>compile
>> the code in a jar to be executed later.
>> I am undergraduate and have not worked on such big project.
>>
>> Some hints will be very helpful.
>>
>> thanks again for the replies.
>>
>> regards,
>> Abhinav Narain
>>
>> On Thu, Jan 20, 2011 at 1:02 PM, Carl Steinbach <ca...@cloudera.com>
>>wrote:
>>
>>> Hi Abhinav,
>>>
>>> 1.
>>> > How does one have access to metastore of Hive, to retrieve the schema
>>> > information from it.
>>> > I cant find a file or other such thing in source code.
>>> >
>>>
>>> Take a look at the IMetaStoreClient interface and HiveMetaStoreClient
>>> class,
>>> but bear in mind that the fundamental definition of the MetaStore
>>> interface
>>> is contained in the Thrift IDL file located
>>> here: metastore/if/hive_metastore.thrift. IMetaStoreClient actually
>>> defines
>>> a wrapper interface around the code generated by the Thrift compiler
>>>based
>>> on the definitions in hive_metastore.thrift
>>>
>>> You can also find some good code examples in TestHiveMetaStore.
>>>
>>>
>>> > 2.
>>> > How does one get the handle of the result that is produced after the
>>> query.
>>> >
>>> > If someone can tell about where to look for the answers, that will
>>>also
>>> > help
>>> >
>>>
>>> Here are the relevant pieces of code that you should look at:
>>>
>>> service/if/hive_service.thrift
>>> service/src/java/org/apache/hadoop/hive/service/HiveServer.java
>>> service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java
>>>
>>> The interface for executing queries and fetching results is defined in
>>> hive_service.thrift and consists of the following methods:
>>>
>>> void execute(string query)
>>> string fetchOne()
>>> list<string> fetchN(i32 numRows)
>>> list<string> fetchAll()
>>>
>>> Since execute() does not return a query ID the Thrift client is
>>>limited to
>>> executing/fetching the results of a single query at a time.
>>>
>>> Hope this helps.
>>>
>>> Carl
>>>
>>
>>
Re: The control flow of hive
Posted by abhinav narain <ab...@gmail.com>.
hi,
I would like to elaborate on what I wish to do.
I want to store the results of hive query in a database instead of just
displaying it on the hive shell.
For this I need to modify/ add code at two places.
1. To fetch the schema from metastore, so that i can create a table in mySql
database
2. Get a handle of a cursor, so that i can dump the result into the
database.
I am unable to figure out how to write my code by implementing an interface
and create jar file so that I can see the results when I run hive again.
I have imported Hive src folder to eclipse, but I am not sure what should I
do next.
Your help would be greatly appreciated.
regards,
Abhinav Narain
On Fri, Jan 21, 2011 at 2:30 PM, abhinav narain
<ab...@gmail.com>wrote:
> Thanks for the prompt replies.
> I have gone through the code.
> But i am unable to understand how can I integrate my own class and compile
> the code in a jar to be executed later.
> I am undergraduate and have not worked on such big project.
>
> Some hints will be very helpful.
>
> thanks again for the replies.
>
> regards,
> Abhinav Narain
>
> On Thu, Jan 20, 2011 at 1:02 PM, Carl Steinbach <ca...@cloudera.com> wrote:
>
>> Hi Abhinav,
>>
>> 1.
>> > How does one have access to metastore of Hive, to retrieve the schema
>> > information from it.
>> > I cant find a file or other such thing in source code.
>> >
>>
>> Take a look at the IMetaStoreClient interface and HiveMetaStoreClient
>> class,
>> but bear in mind that the fundamental definition of the MetaStore
>> interface
>> is contained in the Thrift IDL file located
>> here: metastore/if/hive_metastore.thrift. IMetaStoreClient actually
>> defines
>> a wrapper interface around the code generated by the Thrift compiler based
>> on the definitions in hive_metastore.thrift
>>
>> You can also find some good code examples in TestHiveMetaStore.
>>
>>
>> > 2.
>> > How does one get the handle of the result that is produced after the
>> query.
>> >
>> > If someone can tell about where to look for the answers, that will also
>> > help
>> >
>>
>> Here are the relevant pieces of code that you should look at:
>>
>> service/if/hive_service.thrift
>> service/src/java/org/apache/hadoop/hive/service/HiveServer.java
>> service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java
>>
>> The interface for executing queries and fetching results is defined in
>> hive_service.thrift and consists of the following methods:
>>
>> void execute(string query)
>> string fetchOne()
>> list<string> fetchN(i32 numRows)
>> list<string> fetchAll()
>>
>> Since execute() does not return a query ID the Thrift client is limited to
>> executing/fetching the results of a single query at a time.
>>
>> Hope this helps.
>>
>> Carl
>>
>
>
Re: The control flow of hive
Posted by abhinav narain <ab...@gmail.com>.
Thanks for the prompt replies.
I have gone through the code.
But i am unable to understand how can I integrate my own class and compile
the code in a jar to be executed later.
I am undergraduate and have not worked on such big project.
Some hints will be very helpful.
thanks again for the replies.
regards,
Abhinav Narain
On Thu, Jan 20, 2011 at 1:02 PM, Carl Steinbach <ca...@cloudera.com> wrote:
> Hi Abhinav,
>
> 1.
> > How does one have access to metastore of Hive, to retrieve the schema
> > information from it.
> > I cant find a file or other such thing in source code.
> >
>
> Take a look at the IMetaStoreClient interface and HiveMetaStoreClient
> class,
> but bear in mind that the fundamental definition of the MetaStore interface
> is contained in the Thrift IDL file located
> here: metastore/if/hive_metastore.thrift. IMetaStoreClient actually defines
> a wrapper interface around the code generated by the Thrift compiler based
> on the definitions in hive_metastore.thrift
>
> You can also find some good code examples in TestHiveMetaStore.
>
>
> > 2.
> > How does one get the handle of the result that is produced after the
> query.
> >
> > If someone can tell about where to look for the answers, that will also
> > help
> >
>
> Here are the relevant pieces of code that you should look at:
>
> service/if/hive_service.thrift
> service/src/java/org/apache/hadoop/hive/service/HiveServer.java
> service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java
>
> The interface for executing queries and fetching results is defined in
> hive_service.thrift and consists of the following methods:
>
> void execute(string query)
> string fetchOne()
> list<string> fetchN(i32 numRows)
> list<string> fetchAll()
>
> Since execute() does not return a query ID the Thrift client is limited to
> executing/fetching the results of a single query at a time.
>
> Hope this helps.
>
> Carl
>
Re: The control flow of hive
Posted by Carl Steinbach <ca...@cloudera.com>.
Hi Abhinav,
1.
> How does one have access to metastore of Hive, to retrieve the schema
> information from it.
> I cant find a file or other such thing in source code.
>
Take a look at the IMetaStoreClient interface and HiveMetaStoreClient class,
but bear in mind that the fundamental definition of the MetaStore interface
is contained in the Thrift IDL file located
here: metastore/if/hive_metastore.thrift. IMetaStoreClient actually defines
a wrapper interface around the code generated by the Thrift compiler based
on the definitions in hive_metastore.thrift
You can also find some good code examples in TestHiveMetaStore.
> 2.
> How does one get the handle of the result that is produced after the query.
>
> If someone can tell about where to look for the answers, that will also
> help
>
Here are the relevant pieces of code that you should look at:
service/if/hive_service.thrift
service/src/java/org/apache/hadoop/hive/service/HiveServer.java
service/src/test/org/apache/hadoop/hive/service/TestHiveServer.java
The interface for executing queries and fetching results is defined in
hive_service.thrift and consists of the following methods:
void execute(string query)
string fetchOne()
list<string> fetchN(i32 numRows)
list<string> fetchAll()
Since execute() does not return a query ID the Thrift client is limited to
executing/fetching the results of a single query at a time.
Hope this helps.
Carl
Re: The control flow of hive
Posted by Sreekanth Ramakrishnan <sr...@yahoo-inc.com>.
Hi Abhinav,
If you are looking in source you should start looking at the code in SemanticAnalyser.java
* For actual execution and result handling take a look at the Driver class, this method calls up semantic analyser, generates plans and tasks and takes care of execution. You can take a look at the code flow from there.
* The metadata information is fetched in method getMetadata method in SemanticAnalyser. Which inturn calls BaseSemanticAnalysers db to get metadata information. The protocol used to talk to metastore is thrift.
* And result fetching is done thro fetch operator. You can take a look at the explain extended in the query to see the parameters.
--
Sreekanth
On 1/20/11 11:38 AM, "abhinav narain" <ab...@gmail.com> wrote:
Hi,
I have two questions to ask,
1.
How does one have access to metastore of Hive, to retrieve the schema
information from it.
I cant find a file or other such thing in source code.
2.
How does one get the handle of the result that is produced after the query.
If someone can tell about where to look for the answers, that will also help
regards,
Abhinav
--
Sreekanth Ramakrishnan