Hi Experts, I am trying to write a Hive UDF which access https request and based on the response return the result. From Plain Java, the https response is coming but the https accessed from UDF is null.
Can anyone review the below and share the correct steps to do this. create temporary function profoundIP as 'com.network.logs.udf.ProfoundIp'; select ip,profoundIP(ip) as info from r_distinct_ips_temp; //returns NULL //Below UDF program package com.network.logs.udf; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import javax.net.ssl.HttpsURLConnection; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; public class ProfoundNew extends UDF { private Text evaluate(Text input) { String url = "https://api2.profound.net/ip/" + input.toString() +"?view=enterprise"; URL obj; try { obj = new URL(url); HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setRequestMethod("GET"); con.setRequestProperty("Authorization","ProfoundAuth apikey=cisco-065ccfec619011e38f"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return new Text(response.toString()); } catch (Exception e) { e.printStackTrace(); } return null; } } Thanks, Prabhu Joseph