Re: Accessing sub column in hive
Hi Sai You can do it as Select address.country from employees; Regards Bejoy KS Sent from remote device, Please excuse typos -Original Message- From: Bennie Schut bsc...@ebuddy.com Date: Fri, 8 Mar 2013 09:09:49 To: user@hive.apache.orguser@hive.apache.org; 'Sai Sai'saigr...@yahoo.in Reply-To: user@hive.apache.org Subject: RE: Accessing sub column in hive Perhaps worth posting the error. Some might know what the error means. Also a bit unrelated to hive but please do yourself a favor and don't use float to store monetary values like salary. You will get rounding issues at some point in time when you do arithmetic on them. Considering you are using hadoop you probably have a lot of data so adding it all up will get you there really really fast. http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency From: Sai Sai [mailto:saigr...@yahoo.in] Sent: Thursday, March 07, 2013 12:54 PM To: user@hive.apache.org Subject: Re: Accessing sub column in hive I have a table created like this successfully: CREATE TABLE IF NOT EXISTS employees (name STRING,salary FLOAT,subordinates ARRAYSTRING,deductions MAPSTRING,FLOAT,address STRUCTstreet:STRING, city:STRING, state:STRING, zip:INT, country:STRING) I would like to access/display country column from my address struct. I have tried this: select address[country] from employees; I get an error. Please help. Thanks Sai
Re: Accessing sub column in hive
I recognize this example ;) You reference struct elements with the dot notation, as Bejoy said, map elements with what you tried, deductions['Federal taxes'], and arrays by index, starting from zero, subordinates[0]. On Fri, Mar 8, 2013 at 6:35 AM, bejoy...@yahoo.com wrote: Hi Sai You can do it as Select address.country from employees; Regards Bejoy KS Sent from remote device, Please excuse typos -- *From: * Bennie Schut bsc...@ebuddy.com *Date: *Fri, 8 Mar 2013 09:09:49 +0100 *To: *user@hive.apache.orguser@hive.apache.org; 'Sai Sai' saigr...@yahoo.in *ReplyTo: * user@hive.apache.org *Subject: *RE: Accessing sub column in hive Perhaps worth posting the error. Some might know what the error means. ** ** Also a bit unrelated to hive but please do yourself a favor and don’t use float to store monetary values like salary. You will get rounding issues at some point in time when you do arithmetic on them. Considering you are using hadoop you probably have a lot of data so adding it all up will get you there really really fast. http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency ** ** ** ** *From:* Sai Sai [mailto:saigr...@yahoo.in] *Sent:* Thursday, March 07, 2013 12:54 PM *To:* user@hive.apache.org *Subject:* Re: Accessing sub column in hive ** ** I have a table created like this successfully: ** ** CREATE TABLE IF NOT EXISTS employees (name STRING,salary FLOAT,subordinates ARRAYSTRING,deductions MAPSTRING,FLOAT,address STRUCTstreet:STRING, city:STRING, state:STRING, zip:INT, country:STRING) ** ** I would like to access/display country column from my address struct. I have tried this: ** ** select address[country] from employees; ** ** I get an error. ** ** Please help. ** ** Thanks Sai -- *Dean Wampler, Ph.D.* thinkbiganalytics.com +1-312-339-1330
Re: Accessing sub column in hive
I have a table created like this successfully: CREATE TABLE IF NOT EXISTS employees (name STRING,salary FLOAT,subordinates ARRAYSTRING,deductions MAPSTRING,FLOAT,address STRUCTstreet:STRING, city:STRING, state:STRING, zip:INT, country:STRING) I would like to access/display country column from my address struct. I have tried this: select address[country] from employees; I get an error. Please help. Thanks Sai