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

Posted 阿齐(努力打工版)

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了大数据学习(二十五)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开始
)

以上是关于大数据学习(二十五)hive中的space函数的主要内容,如果未能解决你的问题,请参考以下文章

python学习手册:第二十五章——oop

Python学习笔记(二十五)操作文件和目录

2021年大数据常用语言Scala(二十五):函数式编程 排序

Linux学习(二十五)正则表达式awk

大数据学习(二十三)sql中的排序函数 row_number() rank() dense_rank()

SIGAI机器学习第二十五集 聚类算法2