Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

what is wrong with this UDF ?

what is wrong with this UDF ?

Master Collaborator
package com.demo;
import org.apache.hadoop.hive.ql.exec.UDF;
import java.sql.*;
import oracle.jdbc.*;
import org.apache.hadoop.io.Text;
public class queryp extends UDF {
    public Text evaluate(final Text s) throws SQLException {
    
    //----- below code works fine as a seperate class till EOF ------------
           System.setProperty("oracle.net.tns_admin","/u01/oracle/admin");
           System.setProperty("oracle.net.wallet_location","/u01/oracle/admin");
           String url = "jdbc:oracle:thin:/@secure";
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          Connection conn = DriverManager.getConnection(url);
          Statement stmt = conn.createStatement ();
          ResultSet rset = stmt.executeQuery ("select HOST_NAME,INSTANCE_NAME FROM V$INSTANCE");
          while (rset.next ())
            System.out.println (rset.getString (1));
    // -------------------------- EOF ------------------------------
          return null;
        }
}


> add jar /tmp/hive-udf-0.1-SNAPSHOT.jar;
Added [/tmp/hive-udf-0.1-SNAPSHOT.jar] to class path
Added resources: [/tmp/hive-udf-0.1-SNAPSHOT.jar]
hive> create temporary function qp as 'com.demo.queryp';
OK
Time taken: 0.356 seconds
hive> select qp();
FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments 'qp': No matching method for class com.fdot.demo.querypatron with (). Possible choices: _FUNC_(string)
hive>
1 REPLY 1
Highlighted

Re: what is wrong with this UDF ?

Contributor

Why don't you try with string argument like this?

  1. hive>select qp("hello");
Don't have an account?
Coming from Hortonworks? Activate your account here