Reply
Highlighted
New Contributor
Posts: 5
Registered: ‎09-09-2018

Complex type HIVE: select key/value of a map in a struct and array

[ Edited ]

Hi,

I created this:

 CREATE TABLE schoolparquet (
tipo STRING,
paese STRING,
per_paese ARRAY<STRUCT<sesso:STRING,anni:MAP<STRING,STRING>>>
) STORED AS
PARQUET;

 

>>describe schoolparquet.per_paese.item
| name | type
| sesso | string
| anni | map<string,string>

 

I'm trying to write a query (Impala) that extract key/values from map too, starting from this:

 

select tipo, paese, per_paese.item.sesso
from schoolparquet,
schoolparquet.per_paese;

This works fine.

 

I want to do something like this:

 

select tipo, paese, per_paese.item.sesso,
per_paese.item.anni.key, per_paese.item.anni.value
from schoolparquet,
schoolparquet.per_paese,
schoolparquet.per_paese.anni

 

But I have this error :

ERROR: AnalysisException: Illegal column/field reference 'per_paese.item.anni.value' with intermediate collection 'per_paese' of type 'ARRAY<STRUCT<sesso:STRING,anni:MAP<STRING,STRING>>>'

 

Help please!

 

Thank you

Maria

 

 

 

Announcements