質問

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