You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Mark Kerzner <ma...@shmsoft.com> on 2011/09/29 00:55:41 UTC
Command works inside hive but not outside
Hi, experts,
the same command words in hive shell
add jar WebLogAnalyzer-1.0-SNAPSHOT-jar-with-dependencies.jar; create
temporary function get_browser as "com.shmsoft.webloganalyzer.GetBrowser";
SELECT get_browser(user_agent), COUNT(get_browser(user_agent)) AS
NumOccurrences FROM apache_logs GROUP BY get_browser(user_agent);
but outside,
hive -e 'add jar WebLogAnalyzer-1.0-SNAPSHOT-jar-with-dependencies.jar;
create temporary function get_browser as
"com.shmsoft.webloganalyzer.GetBrowser"; SELECT get_browser(user_agent),
COUNT(get_browser(user_agent)) AS NumOccurrences FROM apache_logs GROUP BY
get_browser(user_agent);'
it gives me an error
FAILED: Error in semantic analysis: Unable to fetch table apache_logs
Thank you,
Mark
Re: Command works inside hive but not outside
Posted by Mark Kerzner <ma...@shmsoft.com>.
Chinna,
I wish it were that simple. This short command works,
hive -e 'select * from apache_logs';
but a long command where I load a jar first, doesn't,
hive -e 'add jar
target/WebLogAnalyzer-1.0-SNAPSHOT-jar-with-dependencies.jar; create
temporary function get_browser as "com.shmsoft.webloganalyzer.GetBrowser";
SELECT get_browser(user_agent), COUNT(get_browser(user_agent)) AS
NumOccurrences FROM apache_logs GROUP BY get_browser(user_agent);'
I see the truth of your words - the table has to be created and used either
all from inside the hive shell, or all from the outside. But I also think
that there is a problem (or at least a problem in the way I use it) with the
long outside command.
Sincerely,
Mark
On Thu, Sep 29, 2011 at 12:40 AM, Chinna Rao Lalam 72745 <
chinnarao@huawei.com> wrote:
> Hi Mark,
>
> I think 'apache_logs' table created from hive shell and select command is
> executed from 'hive -e'(outside) so the hive shell process is different and
> 'hive -e' process is different if derby started in embeded mode(hive by
> default provided embeded derby) it can't see the tables of other processes.
>
> Use derby in network server mode then it can work with the tables created
> from other processes.
>
>
> Hope it helps,
> Chinna
>
> ----- Original Message -----
> From: Mark Kerzner <ma...@shmsoft.com>
> Date: Thursday, September 29, 2011 4:26 am
> Subject: Command works inside hive but not outside
> To: Hive user <us...@hive.apache.org>
>
> > Hi, experts,
> >
> > the same command words in hive shell
> >
> > add jar WebLogAnalyzer-1.0-SNAPSHOT-jar-with-dependencies.jar; create
> > temporary function get_browser as
> > "com.shmsoft.webloganalyzer.GetBrowser";SELECT
> > get_browser(user_agent), COUNT(get_browser(user_agent)) AS
> > NumOccurrences FROM apache_logs GROUP BY get_browser(user_agent);
> >
> > but outside,
> >
> > hive -e 'add jar WebLogAnalyzer-1.0-SNAPSHOT-jar-with-
> > dependencies.jar;create temporary function get_browser as
> > "com.shmsoft.webloganalyzer.GetBrowser"; SELECT
> > get_browser(user_agent),COUNT(get_browser(user_agent)) AS
> > NumOccurrences FROM apache_logs GROUP BY
> > get_browser(user_agent);'
> >
> > it gives me an error
> >
> > FAILED: Error in semantic analysis: Unable to fetch table apache_logs
> >
> > Thank you,
> > Mark
> >
>
Re: Command works inside hive but not outside
Posted by Chinna Rao Lalam 72745 <ch...@huawei.com>.
Hi Mark,
I think 'apache_logs' table created from hive shell and select command is executed from 'hive -e'(outside) so the hive shell process is different and 'hive -e' process is different if derby started in embeded mode(hive by default provided embeded derby) it can't see the tables of other processes.
Use derby in network server mode then it can work with the tables created from other processes.
Hope it helps,
Chinna
----- Original Message -----
From: Mark Kerzner <ma...@shmsoft.com>
Date: Thursday, September 29, 2011 4:26 am
Subject: Command works inside hive but not outside
To: Hive user <us...@hive.apache.org>
> Hi, experts,
>
> the same command words in hive shell
>
> add jar WebLogAnalyzer-1.0-SNAPSHOT-jar-with-dependencies.jar; create
> temporary function get_browser as
> "com.shmsoft.webloganalyzer.GetBrowser";SELECT
> get_browser(user_agent), COUNT(get_browser(user_agent)) AS
> NumOccurrences FROM apache_logs GROUP BY get_browser(user_agent);
>
> but outside,
>
> hive -e 'add jar WebLogAnalyzer-1.0-SNAPSHOT-jar-with-
> dependencies.jar;create temporary function get_browser as
> "com.shmsoft.webloganalyzer.GetBrowser"; SELECT
> get_browser(user_agent),COUNT(get_browser(user_agent)) AS
> NumOccurrences FROM apache_logs GROUP BY
> get_browser(user_agent);'
>
> it gives me an error
>
> FAILED: Error in semantic analysis: Unable to fetch table apache_logs
>
> Thank you,
> Mark
>