大数据入门到精通14--hive 对 字符串的操作
一、基本操作
concat(string,string,string)
concat_ws(string,string,string)
select customer_id,concat_ws(" ",first_name,last_name),email,address_id from customer;
lower(string)
initcap(string)
if 表达式
select customer_id,if (length(first_name)>6 , substring(first_name,0,5),first_name),email,address_id from customer limit 10;
upper(string)
select if (length("abcdefghijk")>6, "a","b");
ltrim(string)
rtrim(string)
trim(string)
length(string)
reverse(string)
split(string,"\\|")
不能直接使用split里面的| 因为那样会把字符串里面的每一个字符都分开,有特定的含义。
select split("abc,def,aaa| bbb",",");
二。高级字符串处理
rpad(string,20," ")
lpad(string,20," ")
regexp_replace(string,"original","dest")
instr(str1,str2),返回字符串中的第几个字符开始
hive> select instr("abcdefadef","def");
OK
4
instr用在where字句中,等同于 like字句。
select film_id,rpad(title,25," "),description from film where lower(description) like "%ancient%";
大数据入门到精通14--hive 对 字符串的操作的更多相关文章
- 大数据入门到精通12--spark dataframe 注册成hive 的临时表
一.获得最初的数据并形成dataframe val ny= sc.textFile("data/new_york/")val header=ny.firstval filterNY ...
- 大数据入门到精通19--mysql 数据导入到hive数据中
一.正常按照数据库和表导入 \\前面介绍了通过底层文件得形式导入到hive的表中,或者直接导入到hdfs中,\\现在介绍通过hive的database和table命令来从上层操作.sqoop impo ...
- 大数据入门到精通18--sqoop 导入关系库到hdfs中和hive表中
一,选择数据库,这里使用标准mysql sakila数据库 mysql -u root -D sakila -p 二.首先尝试把表中的数据导入到hdfs文件中,这样后续就可以使用spark来dataf ...
- 大数据入门到精通13--为后续和MySQL数据库准备
We will be using the sakila database extensively inside the rest of the course and it would be great ...
- 大数据入门到精通11-spark dataframe 基础操作
// dataframe is the topic 一.获得基础数据.先通过rdd的方式获得数据 val ny= sc.textFile("data/new_york/")val ...
- 大数据入门到精通2--spark rdd 获得数据的三种方法
通过hdfs或者spark用户登录操作系统,执行spark-shell spark-shell 也可以带参数,这样就覆盖了默认得参数 spark-shell --master yarn --num-e ...
- 大数据入门到精通16--hive 的条件语句和聚合函数
一.条件表达 case when ... then when .... then ... when ... then ...end select film_id,rpad(title,20," ...
- 大数据入门到精通15--hive 对 date类型的处理
一.基础日期处理 //date 日期处理select current_date;select current_timestamp;//to_date(time) ;to_date(string)sel ...
- 大数据入门到精通10--spark rdd groupbykey的使用
//groupbykey 一.准备数据val flights=sc.textFile("data/Flights/flights.csv")val sampleFlights=sc ...
随机推荐
- java.net.BindException: Address already in use: JVM_Bind:80 异常的解决办法
今天遇见了这个端口被占用问题 然后各种百度 先是说 用命令 netstat -a -n -o 最后一个选项表示连接所在进程id. 找到8080端口的PID然后打开任务管理器, 切换到进程选项卡, 在菜 ...
- PHP输出缓存ob系列函数详解
PHP输出缓存ob系列函数详解 ob,输出缓冲区,是output buffering的简称,而不是output cache.ob用对了,是能对速度有一定的帮助,但是盲目的加上ob函数,只会增加CPU额 ...
- PC timeline
https://news.microsoft.com/facts-about-microsoft/ 日期 事件 1975年 微软成立 1981年 ...
- Tarjan求割点&桥
概念 1.桥:是存在于无向图中的这样的一条边,如果去掉这一条边,那么整张无向图会分为两部分,这样的一条边称为桥无向连通图中,如果删除某边后,图变成不连通,则称该边为桥. 2.割点:无向连通图中,如果删 ...
- Python开发 標準內建方法 (未完代補)
abs(number) 絕對值 The abs() method takes a single argument: num - number whose absolute value is to ...
- linux环境下安装nginx步骤(不错)
开始前,请确认gcc g++开发类库是否装好,默认已经安装. ububtu平台编译环境可以使用以下指令 apt-get install build-essential apt-get install ...
- js正则表达式讲的最好的
https://www.cnblogs.com/chenmeng0818/p/6370819.html
- 装系统时 System clock uses UTC 问题
装系统也装了至少不下50次了,每次都是傻瓜一样的按照第一印象在弄,从未想过为啥,装到这里的时候,System clock uses UTC 勾不勾呢,每次都是百度,然后装完这一次下一次又忘了,这是没有 ...
- Hystrix 学习使用
说明: 每次调用创建一个新的HystrixCommand,把依赖调用封装在run()方法中 执行execute()/queue做同步或异步调用 请求接收后,会先看是否存在缓存数据,如果存在,则不会继续 ...
- golang cache--go-cache
go-cache是一款类似于memached 的key/value 缓存软件.它比较适用于单机执行的应用程序. go-cache实质上就是拥有过期时间并且线程安全的map,可以被多个goroutine ...