Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
what is wrong with this UDF ?
Labels:
Super Collaborator
Created ‎10-19-2018 08:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Rising Star
Created ‎10-23-2018 04:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why don't you try with string argument like this?
- hive>select qp("hello");
