0


大数据学习(二十五)hive中的space函数

1.空格字符串函数:space

语法:space(int n)

返回值:string

说明:返回长度为n的空格字符串

举例:

hive> select space(10) from dual;
hive> select length(space(10)) from dual;
10

2.space函数与split函数结合,得到数组

space函数与split函数结合,可以得到空格字符串数组

hive>select split(space(10), '');
[" "," "," "," "," "," "," "," "," "," ",""]

3.可以通过space函数和split函数,得到连续数字

select 
    start+a_id as number_1_100
from
(
select
    1 as start 
from dual
lateral view posexplode(split(space(100),'') tmp_a as a_id,a_index -- a_id为posexplode产生的序号,从0开始
)
标签: 学习

本文转载自: https://blog.csdn.net/weixin_44702289/article/details/128892256
版权归原作者 阿齐(努力打工版) 所有, 如有侵权,请联系我们删除。

“大数据学习(二十五)hive中的space函数”的评论:

还没有评论