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

How to deal with null and\ N in Hive

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "how to deal with null and\N in Hive". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "Hive null and\N how to deal with it"!

Hive has a false NULL that looks exactly like NULL, but is not NULL. NULL is stored as '\N' by default at the bottom level, and we habitually filter NULL values, usually is null and is not null. Therefore, at this time, you can modify the information in the hive table to ensure that the control is displayed as the specified value, which is convenient for filtering. The solution is as follows:

(1) As follows:

alter table t_dw_ct_author set serdeproperties ('serialization.null.format' = 'NULL');

Then it appears: the underlying data is stored as 'NULL', and the query shows 'NULL'

In this case, if the query is null, the field can be passed through the statement: a is null or a='NULL'

or

alter table t_dw_ct_author set serdeproperties('serialization.null.format' = '\N');

Then it appears: the underlying data is saved as '\N', and the query shows'NULL'

In this case, if the query is null, the field can be passed through the statement: a is null or a='\\N'

(2)'' and length (xx)=0

'' indicates that the field is not null and is an empty string. In this case, a is null cannot query this value. It must be queried by a='' or length(a)=0.

At this point, I believe that everyone has a deeper understanding of "Hive null and\Nhow to deal with", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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