0
FROM cr_expanded_crcs_halen c INSERT OVERWRITE TABLE merge_result SELECT 'crcs', operator_id, instance_id, ts, user, application, actualconn, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL

我尝试使用上面的带有jdbc的sql将数据插入表merge_result,发现错误如下

Exception in thread "main" java.sql.SQLException: Error running query: java.lang.NullPointerException
at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:159)
at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:147)
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:182)
at org.apache.solr.handler.dataimport.scheduler.HiveClient.main(HiveClient.java:63)
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:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

但数据已成功插入。任何机构可以帮助我?

4

1 回答 1

0

我有同样的错误。不幸的是,我找不到失败的原因,但我找到了解决方法。当您在 JDBC 的选择语句中使用 NULL 一词时会出现问题,我丑陋的解决方案是用 udf "null_value()" 替换 NULL

我会用这个问题打开一个jira

@Description(name="null_value", value="_FUNC() return null")
@UDFType(deterministic=true, stateful=false)
public class NullValue extends GenericUDF {


    @Override
    public ObjectInspector initialize(ObjectInspector[] arguments)
            throws UDFArgumentException {
        return PrimitiveObjectInspectorFactory.javaStringObjectInspector;
    }

    @Override
    public Object evaluate(DeferredObject[] arguments) throws HiveException {
        return null;
    }

    @Override
    public String getDisplayString(String[] children) {
        return "keys_to_lower_"+children[0];
    }

}

谢谢,加博

于 2013-08-23T03:56:52.960 回答