문제

Is it possible to execute a Sql on Hive itself from inside a Hive UDF? I tried doing it using below snippet:

        Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");

        Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");

but this gave me a connection refused error, whereas I am able to telnet to the port from machine itself.

도움이 되었습니까?

해결책

Hive UDFs are executed on the task nodes. Unless you're running hive server on every task node (hopefully not), giving the connection URL as "localhost:10000" will not work. You must give it the actual address of the hive server node, whether that is an actual name (e.g. my-hive-server-node.company.com:10000) or just an ip (e.g. 10.20.30.40:10000).

Also, I would really take a step back and make sure this is really what you want to do. This seems like it's really against the intentions of Hive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top