当向已经分区的表插入数据时,有可能会报错:
Need to specify partition columns because the destination table is partition
原因是需要在插入的数据中指定分区字段的数值是多少。
比如:
建表语句:
create table test (
starttime string,
endtime string,
title string
)
PARTITIONED BY (username string)
ROW FO……
需求:
表table中存在一个text字段,需要统计出文本长度为[0,20]、[20,40]、[40,60]…按区间划分的数量。其中,需要自动化到包含最大值max的区间。
实现:
第一种方法:
select count(case when length(text) between 0 and 20 then 1 end) as text1,
count(case when length(text) between 21 and 40 then 1 end) as tex……