Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Hive complex type access operation

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Complex type access operation 1. Array type access: a [n]

Syntax: a [n]

Operation type: an is array type, n is int type

Description: returns the nth variable value in array A. The starting subscript of the array is 0. For example, if An is an array type with a value of ['foo',' bar'], then A [0] will return 'foo',' and A [1] will return 'bar''

For example:

Hive > create table lxw_test as selectarray ("tom", "mary", "tim") as t from lxw_dual

Hive > select t [0], t [1], t [2] from lxw_test

Tom mary tim

2. Map type access: M [key]

Syntax: M [key]

Operation type: M is the map type, and key is the key value in map

Description: returns the map type M where the key value is the value of the specified value. For example, if M is a map type with a value of {'f'- > 'foo',' bounded-> 'bar',' all'-> 'foobar'}, then M [' all'] will return 'foobar''

For example:

Hive > Create table lxw_test as selectmap ('100th and 2000s) as t from lxw_dual

Hive > select t ['200'], t [' 100'] from lxw_test

Mary tom

3. Struct type access: S.X

Syntax: S.X

Operation type: s is struct type

Description: returns the x field in structure S. For example, for the structure struct foobar {int foo, int bar}, foobar.foo returns the foo field in the structure

For example:

Hive > create table lxw_test as select struct ('tom','mary','tim') as t from lxw_dual

Hive > describe lxw_test

T struct

Hive > select t.col1mt. Col3 from lxw_test

Tom tim

For more exciting content, please follow: http://bbs.superwu.cn

Follow the Superman College Wechat QR code:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report