hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "@Sanjiv Singh" <sanjiv.is...@gmail.com>
Subject Re: Hive Update : Null Pointer Exception while using If statement
Date Fri, 24 Jul 2015 07:03:02 GMT
What is the type of employee.id ? it is integer , then change insert
statement to :


insert overwrite table employee_incr select employee.id,employee.ename,if(
employee.id= 1 ,12,employee.id ) as employee.id from employee;

Regards
Sanjiv Singh
Mob :  +091 9990-447-339

On Fri, Jul 24, 2015 at 11:10 AM, Shashi Vishwakarma <
shashi.vish123@gmail.com> wrote:

> Hi Experts,
>
> I have table in hive in which i have to update certain records. I am using
> hive 0.13 version. I did bit of googling and found that i can use If-Else
> statement with insert overwrite for doing this but after running a query it
> is throwing null pointer exception.
>
> Here is my Employee table:
>
> 1 emp1
> 2 emp2
> 3 emp3
> 4 emp4
> 5 emp5
>
> I created another table employee_incr with same schema as employee and ran
> this query to get updated records.
>
> insert overwrite table employee_incr select employee.id,employee.ename,if(
> employee.id=”1″,12,employee.id ) as employee.id from employee;
>
> Here is trace from Hive.
>
> 2015-07-24 09:55:05,351 INFO [main]: session.SessionState
> (SessionState.java:start(361)) – No Tez session required at this point.
> hive.execution.engine=mr.
> 2015-07-24 09:55:05,391 INFO [main]: log.PerfLogger
> (PerfLogger.java:PerfLogBegin(108)) – <PERFLOG method=Driver.run
> from=org.apache.hadoop.hive.ql.Driver>
> 2015-07-24 09:55:05,392 INFO [main]: log.PerfLogger
> (PerfLogger.java:PerfLogBegin(108)) – <PERFLOG method=TimeToSubmit
> from=org.apache.hadoop.hive.ql.Driver>
> 2015-07-24 09:55:05,392 INFO [main]: ql.Driver
> (Driver.java:checkConcurrency(159)) – Concurrency mode is disabled, not
> creating a lock manager
> 2015-07-24 09:55:05,395 INFO [main]: log.PerfLogger
> (PerfLogger.java:PerfLogBegin(108)) – <PERFLOG method=compile
> from=org.apache.hadoop.hive.ql.Driver>
> 2015-07-24 09:55:05,422 INFO [main]: log.PerfLogger
> (PerfLogger.java:PerfLogBegin(108)) – <PERFLOG method=parse
> from=org.apache.hadoop.hive.ql.Driver>
> 2015-07-24 09:55:05,426 INFO [main]: parse.ParseDriver
> (ParseDriver.java:parse(185)) – Parsing command: insert overwrite table
> employee_incr select employee.id,employee.ename,if(employee.id=1,12,
> employee.id ) as employee.id from employee
> 2015-07-24 09:55:05,709 ERROR [main]: ql.Driver
> (SessionState.java:printError(547)) – FAILED: NullPointerException null
> java.lang.NullPointerException
> at
> org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:37646)
> at
> org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:36884)
> at
> org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:36760)
> at
> org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1338)
> at
> org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1036)
> at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
> at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
> at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:409)
> at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:323)
> at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:980)
> at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1045)
> at org.apache.hadoop.hive.ql.Driver.run(Driver.java:916)
> at org.apache.hadoop.hive.ql.Driver.run(Driver.java:906)
> at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:268)
> at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
> at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:423)
> at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:359)
> at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:743)
> at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
> at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
>
> Any help here?
>
> Thanks
>
> Shashi
>

Mime
View raw message