To start with, you can remove the try-catch so that the exception is not swallowed and you can see if an error occurs. However, note that this is an anti-pattern for any reasonable-sized dataset.
From: Prabhu Joseph <prabhujose.ga...@gmail.com<mailto:prabhujose.ga...@gmail.com>> Reply-To: "u...@hive.apache.org<mailto:u...@hive.apache.org>" <u...@hive.apache.org<mailto:u...@hive.apache.org>> Date: Friday, January 8, 2016 at 00:51 To: "u...@hive.apache.org<mailto:u...@hive.apache.org>" <u...@hive.apache.org<mailto:u...@hive.apache.org>>, "dev@hive.apache.org<mailto:dev@hive.apache.org>" <dev@hive.apache.org<mailto:dev@hive.apache.org>> Subject: Hive UDF accessing https request 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