Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to query a column name 'date' in hive?

Tags:

hive

Date is a reserved word in hive, but I have a table with column name 'date'. Every time I do "select date from mytable", it gives me an error.

Is there any way to query this column?

like image 499
javier quiroz Avatar asked Jan 29 '15 21:01

javier quiroz


People also ask

How do I SELECT columns in Hive?

The easiest way to select specific columns in the Hive query is by specifying the column name in the select statement. SELECT col1, col3, col4 .... FROM Table1; But imagine your table contains many columns (i.e : more than 100 columns) and you need to only exclude a few columns in the select statement.

How do I search for a column in Hive database?

select TBL_NAME, COLUMN_NAME, TYPE_NAME from TBLS left join COLUMNS_V2 on CD_ID = TBL_ID where COLUMN_NAME like 'column'; where 'column' is the column name you're looking for.


1 Answers

(backward apostrophe)date (backward apostrophe) - works well

SELECT HD1.holidaydate as holiday_date, HD1.hub_id as holiday_hub_id, to_date(HD2.`date`), HD2.dateno as holiday_dateno
FROM table1 HD1 LEFT OUTER JOIN table2 HD2 ON HD1.holidaydate = to_date(HD2.`date`)
like image 176
user6414531 Avatar answered Jan 03 '23 11:01

user6414531