Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display the SQL definition of a hive view

Tags:

hadoop

hive

How to display the view definition of a hive view in its SQL form. Most relational databases supports commands like

SHOW CREATE VIEW viewname;

like image 487
rogue-one Avatar asked Jul 04 '14 19:07

rogue-one


People also ask

How do you find the definition of view in Hive?

For a view, DESCRIBE EXTENDED or FORMATTED can be used to retrieve the view's definition. Two relevant attributes are provided: both the original view definition as specified by the user, and an expanded definition used internally by Hive.

How do I find the details of a Hive database?

To list out the databases in Hive warehouse, enter the command 'show databases'. The database creates in a default location of the Hive warehouse. In Cloudera, Hive database store in a /user/hive/warehouse. Copy the input data to HDFS from local by using the copy From Local command.

How do you query a view in Hive?

You can create a view at the time of executing a SELECT statement. The syntax is as follows: CREATE VIEW [IF NOT EXISTS] view_name [(column_name [COMMENT column_comment], ...) ]

How do I get a list of views in Hive database?

However, if the Hive Metastore is configured using a Derby MySQL server then you can access the information you require. Show activity on this post. Run this code from as sh find_views.sh dbname . Now the table all_views has the list of views.


2 Answers

Use show create table.

Read the hive manual for more detail.

like image 179
pensz Avatar answered Sep 19 '22 16:09

pensz


It is DESCRIBE [EXTENDED|FORMATTED] also. show create table doesn't give enough information sometimes, but DESCRIBE always does;

For a view, DESCRIBE EXTENDED or FORMATTED can be used to retrieve the view's definition. Two relevant attributes are provided: both the original view definition as specified by the user, and an expanded definition used internally by Hive.

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-DescribeTable/View/Column

like image 38
aryndin Avatar answered Sep 22 '22 16:09

aryndin