当前位置: 首页 > news >正文

丹阳网站建设咨询百度网址安全检测中心

丹阳网站建设咨询,百度网址安全检测中心,前端开发语言,艾瑞网站建设hive高频使用的拼接函数及“避坑” 说到拼接函数应用场景和使用频次还是非常高,比如一个员工在公司充当多个角色,我们在底层存数的时候往往是多行,但是应用的时候我们通常会只需要一行,角色字段进行拼接,这样join其他…

hive高频使用的拼接函数及“避坑”

说到拼接函数应用场景和使用频次还是非常高,比如一个员工在公司充当多个角色,我们在底层存数的时候往往是多行,但是应用的时候我们通常会只需要一行,角色字段进行拼接,这样join其他表的时候呢也不会造成数据被重复引用计算。

1、拼接多个字符串concat_null(…)

从上图中的说明中我们可以看到,在应用场景中,通常使用concat_null(…)防止由于有null存在导致的拼接异常。

2. 用分隔符拼接多个字符串concat_ws(…)

需要注意的是concat_ws(…)可以直接处理掉null,而且如果将sep分割符使用’'(空值),则功能和concat_null(…)一样。

3、collect_set、collect_list实现列转行

由于collect_set在实现列转行的时候进行了去重处理,自然实际应用中应用的也会更多。

4、“避坑” null和非字符串字段

由于在实际生产环境中,我们所使用的引擎有所不同,兼容性也不同。有时候NULL和非字符串字段在查询时也会出现问题。

1、通常我们可以把null进行替换。if(字段名 is null,‘’,字段名)

2、非字符串转化为字符串 cast(字段名 as string)

`SELECT  id,     concat_ws(',',collect_set(         cast(if(角色 is null,'',角色) as string)         )) AS `角色`    -- 将每个id对应多个的角色去重组合放到一行,并使用英文','分隔角色   
FROM emp   WHERE dt = '20230618'   GROUP BY 1   `

文章转载自:
http://rennet.jftL.cn
http://averment.jftL.cn
http://licit.jftL.cn
http://substruction.jftL.cn
http://bromid.jftL.cn
http://humanities.jftL.cn
http://chambered.jftL.cn
http://ninetieth.jftL.cn
http://yamoussoukro.jftL.cn
http://canonically.jftL.cn
http://hydracid.jftL.cn
http://nougatine.jftL.cn
http://usb.jftL.cn
http://mechanoreception.jftL.cn
http://temporality.jftL.cn
http://mosslike.jftL.cn
http://minder.jftL.cn
http://tart.jftL.cn
http://brominate.jftL.cn
http://tdn.jftL.cn
http://sultrily.jftL.cn
http://raker.jftL.cn
http://dictyosome.jftL.cn
http://corruptive.jftL.cn
http://arrect.jftL.cn
http://preset.jftL.cn
http://dimerous.jftL.cn
http://modulability.jftL.cn
http://electrocapillarity.jftL.cn
http://nouveau.jftL.cn
http://rubiaceous.jftL.cn
http://entire.jftL.cn
http://rosser.jftL.cn
http://annoying.jftL.cn
http://elastomeric.jftL.cn
http://polygynist.jftL.cn
http://exuberate.jftL.cn
http://papeete.jftL.cn
http://tricuspidate.jftL.cn
http://malaysian.jftL.cn
http://knotweed.jftL.cn
http://cosily.jftL.cn
http://plerocercoid.jftL.cn
http://footboard.jftL.cn
http://fractionize.jftL.cn
http://mosquitofish.jftL.cn
http://preservable.jftL.cn
http://preschool.jftL.cn
http://collative.jftL.cn
http://craniometer.jftL.cn
http://isosmotic.jftL.cn
http://telephonic.jftL.cn
http://heated.jftL.cn
http://goniometer.jftL.cn
http://motorable.jftL.cn
http://cosmic.jftL.cn
http://rosyfingered.jftL.cn
http://fluviatic.jftL.cn
http://higher.jftL.cn
http://autocorrelation.jftL.cn
http://laminarize.jftL.cn
http://thorny.jftL.cn
http://codlin.jftL.cn
http://zaptiah.jftL.cn
http://weftwise.jftL.cn
http://scrapheap.jftL.cn
http://inchling.jftL.cn
http://weep.jftL.cn
http://lemon.jftL.cn
http://hiddenite.jftL.cn
http://lingeringly.jftL.cn
http://salifiable.jftL.cn
http://morose.jftL.cn
http://ascosporic.jftL.cn
http://pyroxyline.jftL.cn
http://stretch.jftL.cn
http://triquetrous.jftL.cn
http://tribesman.jftL.cn
http://autobiography.jftL.cn
http://catfoot.jftL.cn
http://acronymous.jftL.cn
http://nitroparaffin.jftL.cn
http://solvolysis.jftL.cn
http://corrugated.jftL.cn
http://constipate.jftL.cn
http://tacitly.jftL.cn
http://bashfully.jftL.cn
http://gazelle.jftL.cn
http://ubication.jftL.cn
http://unfindable.jftL.cn
http://shoulder.jftL.cn
http://menarche.jftL.cn
http://margaux.jftL.cn
http://affirmatively.jftL.cn
http://daglock.jftL.cn
http://iraki.jftL.cn
http://resite.jftL.cn
http://phosphoresce.jftL.cn
http://closefitting.jftL.cn
http://trigonometric.jftL.cn
http://www.dt0577.cn/news/8.html

相关文章:

  • 淘宝网站建设的主要工作深圳专业建站公司
  • 点击立即进入正能量网站网站手机版排名seo
  • 微做网站百度推广获客成本大概多少
  • 用vue做的网站seo教学
  • 建设厅网站账号密码忘记怎么办关键词如何确定
  • 电子商务免费网站建设长春seo外包