hive SELECT Statement Select: Project selected columns


Example

Sample table (say Employee) structure

Column NameDatatype
IDINT
F_NameSTRING
L_NameSTRING
PhoneSTRING
AddressSTRING

Project all the columns

Use wild card * to project all the columns. e.g.

Select * from Employee

Project selected columns (say ID, Name)

Use name of columns in the projection list. e.g.

Select ID, Name from Employee

Discard 1 column from Projection list

Display all columns except 1 column. e.g.

Select `(ID)?+.+` from Employee

Discard columns matching pattern

Reject all columns which matches the pattern. e.g. Reject all the columns ending with NAME

Select `(.*NAME$)?+.+` from Employee