Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create view in Hive with spaces in column names

Tags:

hive

In Hive 0.7, is there any way to create a view with spaces in the column name? In SQL Server I'd do:

CREATE VIEW test_vw
AS 
SELECT col_name as [col name with spaces]
FROM   test_tbl;

Is there a hive equivalent?

We need the view with names for use by end user tools.

like image 202
Stagg Avatar asked Jul 04 '14 08:07

Stagg


2 Answers

From Hive documentation:

In Hive 0.12 and earlier, only alphanumeric and underscore characters are allowed in table and column names.

In Hive 0.13 and later, column names can contain any Unicode character (see HIVE-6013). Any column name that is specified within backticks (`) is treated literally

like image 188
Santiago Cepas Avatar answered Sep 28 '22 17:09

Santiago Cepas


You can use

CREATE VIEW test_vw
AS 
SELECT col_name as `col name with spaces`
FROM   test_tbl;
like image 43
Senfida Avatar answered Sep 28 '22 18:09

Senfida