シリーズハイブハイブ共通データクリーニング機能を学習

図1に示すように、ケース例えば使用、洗浄又は格付けなどのようなコンテンツ、使用。

case 
   when new.comment_grade = '五星商户' then 50
   when new.comment_grade = '准五星商户' then 45
   when new.comment_grade = '四星商户' then 40
   when new.comment_grade = '准四星商户' then 35
   when new.comment_grade = '三星商户' then 30
   when new.comment_grade = '准三星商户' then 25
   when new.comment_grade = '二星商户' then 20
   when new.comment_grade = '准二星商户' then 15
   when new.comment_grade = '一星商户' then 10
   when new.comment_grade = '准一星商户' then 5
   when new.comment_grade = '该商户暂无星级' then 0
   when new.comment_grade is NULL then old.comment_grade
   else new.comment_grade
END as `new.comment_grade`,

   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

2、文字列の内容の一部を置き換えます。

regexp_replace(new.avg_price, '-', '')
替换 avg_price 中的中划线。

   
   
  • 1
  • 2

3、文字列のセグメンテーション機能

split(a.tag_flag, '>')[1],
具体例子:
select split('a,b', ',')[0]  ===> 结果 a

   
   
  • 1
  • 2
  • 3

図4に示すように、文字列の連結機能

SELECT concat('1', '2');     ====》 结果 12
SELECT concat('1', '2', '3');   ===> 结果 123 

図5に示すように、ブランクのストリングの両端が除去され

  • 1
  • 2
  • 3
  • 4
  • 5

トリム(a.city)


  • 1
  • 2

6、左が参加するか、右の補完データを使用して参加します

例如根据两张表,其中一张表格table2含有省份和城市的信息,
其中一张表table1只有城市信息,需要补全table1 中的省份信息,可以像如下做法:
select 
	a.name,
	b.province,
	a.city
from table1 a left join table2 b on  a.city = b.city;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

7、その他:条件を満たしていないデータをクリアします

可以使用等值判断来处理数据
清除一些不符合条件的数据。
INSERT OVERWRITE table ods.js_beauty_tmp
SELECT *
from ods.js_beauty_tmp
WHERE map_lat != ''
AND map_lng != ''
AND map_lat IS NOT NULL
AND map_lng IS NOT NULL
AND map_lat != 0
AND map_lng != 0
AND map_lat not like '-%'
AND map_lng not like '-%'
and city != '其他城市'
and city != '点评实验室';

  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
      </div>

おすすめ

転載: blog.csdn.net/weixin_42177380/article/details/90713177