Support Questions

Find answers, ask questions, and share your expertise

Get Database name within Hive UDF

New Contributor

Hello,

Is there a way to get the database name in which a Hive UDF is deployed in? The reason I need this is because we use that as parameters to do different things in different databases.

Thanks

1 REPLY 1

Master Collaborator

If you are trying to determine the current database in your custom Hive UDF code, this should help

https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/UDFCurr...

From beeline / hive cli you can check by running:

0: jdbc:hive2://localhost> select current_database();
+----------+--+
|   _c0    |
+----------+--+
| default  |
+----------+--
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.