Use inline (ARRAY <STRUCT [, STRUCT]>) in Hive

Someone could use this function before, I tried almost any combination to see if it works.

This is the Struct array that I am trying to use with inline

[{"position":1,"price":124.0,"card_pos":"External","clicked":0},
 {"position":2,"price":94.78,"card_pos":"Cbox","clicked":0},
 {"position":3,"price":94.77,"card_pos":"External","clicked":0}] 

This works well:

select iq.*, iq.card.position as position, 
iq.card.price as price,iq.card.card_pos as card_pos, 
iq.card.clicked as clicked 
from
(
  select *
  from 
  hsim.im_metasearch
  LATERAL VIEW explode(cards) card as card
) iq

It is annoying that I can make the inline function work. The documentation on the Wive Wiki is very vague about how this function should be used properly.

We have Hive 0.10 (CDH4.6), the inline function is definitely part of our distribution.

If anyone has a specific example of how to use it, please let me know

I tried a couple of different syntaxes

select *
from 
hsim.im_metasearch
Lateral view inline(cards) as(position,price,card_pos,clicked)

select *
from 
hsim.im_metasearch
Lateral view inline(cards) card as (position,price,card_pos,clicked)

I also tried to include it in the selection without success Thank you

+4
3

, () inline. , ,

id    |    num
---------------
1          2.0
1          4.0
2          5.0
1          7.0
1          8.0
2          8.0
1          3.0
1          5.0
1          6.0
3          7.0

select histogram_numeric(num, 3)
from table

, 3 , .

[{'x':2.5, 'y:2.0'}, {'x':5.0, 'y':4.0}, {'x':7.5, 'y':4.0}]

- , , inline. ,

select inline(histogram_numeric(num, 3))
from table

x    |    y
-------------
2.5      2.0
5.0      4.0
7.5      4.0

, .

+3

select * 
from table1 t
   lateral view inline(array_of_structs) a
;
+2

Query:

select * from ( select ARRAY(named_struct('a1', 1, 'a2', 2)) as kk  from dim_one_row ) x lateral view  inline(kk)  t as ff, ff2;

Result:

[{"a1":1,"a2":2}]       1       2
0
source

All Articles