Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

what is wrong with this UDF ?

avatar
Super 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

avatar
Rising Star

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

  1. hive>select qp("hello");