I am creating a table in hive;
create table patients(
patient_id INT,
age_group STRING,
gender STRING,
income_range STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ';
load data local inpath '/mnt/patients.csv' into table patients;
Now when I am using the command:
hive>select * from patients limit 5;
I am getting the output:
NULL 75-84, F, 32000-47999
NULL 75-84, M, 16000-23999
NULL 85+, M, <16000
NULL 65-74, F, 32000-47999
NULL <65, M, <16000
But when I am using assigning patient_id as string its showing:
910997967, 75-84, F, 32000-47999
506013497, 75-84, M, 16000-23999
432041392, 85+, M, <16000
633048699, 65-74, F, 32000-47999
I tried to use :
hive>select CAST(patient_id AS int) from patients;
But its not changing the values to int and only showing
NULL
NULL
...
How could the values of patient_id can be converted to int values?
Thanks
CASTwill work correctly.