Wrong arguments '"Male"': org.apache.hadoop.hive.ql.metadata.HiveException | Drools KieSession in HiveUDF

Sam Source

I'm trying to develop a UDF with drools rule engine invocation inside evaluate method using the code below:

Person person = new Person(gender);

    KieServiceSerializer kszObj = new KieServiceSerializer();

    KieServices ks = kszObj.getKieServices();
    KieContainer kContainer = ks.getKieClasspathContainer();
    KieSession kSession = kContainer.newKieSession("ksession-rules");   //this line is causing error: Wrong arguments '"Male"': org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public java.lang.String org.udf_drools_poc.UDFDrools.evaluate(java.lang.String)

    kSession.insert(person);
    kSession.fireAllRules();

Both Person and KieServiceSerializer are serialized.

This code works fine locally (when executed from IDE) but throws following error when executed through hive:

Wrong arguments '"Male"': org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public java.lang.String org.udf_drools_poc.UDFDrools.evaluate(java.lang.String)

Invoking UDF using the script below:

create temporary function genderMap as 'org.udf_drools_poc.UDFDrools';
select genderMap("Male");

Any suggestions?

Thanks.

hadoophivedroolsuser-defined-functions

Answers

comments powered by Disqus