javier quiroz
javier quiroz

Reputation: 79

how to query a column name 'date' in 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?

Upvotes: 8

Views: 10375

Answers (3)

PtrWrangler
PtrWrangler

Reputation: 21

Using back-ticks worked for me!

e.g. `date` DATE

Upvotes: 1

user6414531
user6414531

Reputation: 71

(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`)

Upvotes: 7

javier quiroz
javier quiroz

Reputation: 79

I used "date" or 'date' -one or the other, and it worked. I just need to put the reserved word between quotes '' Example...

Select 'date' from mytable;

:)

Upvotes: -1

Related Questions