大数据入门到精通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 ...
随机推荐
- Reasoning With Neural Tensor Networks For Knowledge Base Completion-paper
https://www.socher.org/index.php/Main/ReasoningWithNeuralTensorNetworksForKnowledgeBaseCompletion 年份 ...
- MySQL5.7.32 通用版本安装
1 上传镜像,配置好yum源 2 下载MySQL相关的包 https://dev.mysql.com/downloads/mysql/ 3 解压安装: tar -zxvf mysql-5.7.23- ...
- 学习笔记TF038:实现估值网络
Q-Learning,学习Action对应期望值(Expected Utility).1989年,Watkins提出.收敛性,1992年,Watkins和Dayan共同证明.学习期望价值,从当前一步到 ...
- 第二章 JavaScript案例(中)
1. js事件 HTML代码 <!DOCTYPE html> <html lang="en" onUnload="ud()"> < ...
- HBase各版本对Hadoop版本的支持情况
转载自:http://blog.csdn.net/sunny05296/article/details/54089194 安装HBase时,要考虑选择正确的Hadoop版本,否则可能出现不兼容的情况. ...
- 使用lite-server
进入项目根目录,执行下列步骤 安装lite-server npm install lite-server 新建配置文件bs-config.json bs-config.json中可以: 指定监听的端口 ...
- ByteToByte64String、Base64StringToBytes
public string ByteToByte64String(byte[] bytes) { return Convert.ToBase64String(bytes); } public byte ...
- 对poi-excel导出的浅层理解
上一篇对excel导入做了浅层的解释,本文将对导出再做浅层解释. 仍然是相同的套路,只不过是反过来而已. 反过来方向理论上本来是这样的:cell-->row-->sheet-->wo ...
- mmap映射区和shm共享内存的区别总结
[转载]原文链接:https://blog.csdn.net/hj605635529/article/details/73163513 linux中的两种共享内存.一种是我们的IPC通信System ...
- 高阶函数map_reduce_sorted_filter
能够把函数当成参数传递的参数就是高阶函数 map map: 功能: 拿iterable的每一个元素放入func中, func的返回值放入迭代器内进行返回 参数: iterable, func 返回: ...