一、基本操作

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 对 字符串的操作的更多相关文章

  1. 大数据入门到精通12--spark dataframe 注册成hive 的临时表

    一.获得最初的数据并形成dataframe val ny= sc.textFile("data/new_york/")val header=ny.firstval filterNY ...

  2. 大数据入门到精通19--mysql 数据导入到hive数据中

    一.正常按照数据库和表导入 \\前面介绍了通过底层文件得形式导入到hive的表中,或者直接导入到hdfs中,\\现在介绍通过hive的database和table命令来从上层操作.sqoop impo ...

  3. 大数据入门到精通18--sqoop 导入关系库到hdfs中和hive表中

    一,选择数据库,这里使用标准mysql sakila数据库 mysql -u root -D sakila -p 二.首先尝试把表中的数据导入到hdfs文件中,这样后续就可以使用spark来dataf ...

  4. 大数据入门到精通13--为后续和MySQL数据库准备

    We will be using the sakila database extensively inside the rest of the course and it would be great ...

  5. 大数据入门到精通11-spark dataframe 基础操作

    // dataframe is the topic 一.获得基础数据.先通过rdd的方式获得数据 val ny= sc.textFile("data/new_york/")val ...

  6. 大数据入门到精通2--spark rdd 获得数据的三种方法

    通过hdfs或者spark用户登录操作系统,执行spark-shell spark-shell 也可以带参数,这样就覆盖了默认得参数 spark-shell --master yarn --num-e ...

  7. 大数据入门到精通16--hive 的条件语句和聚合函数

    一.条件表达 case when ... then when .... then ... when ... then ...end select film_id,rpad(title,20," ...

  8. 大数据入门到精通15--hive 对 date类型的处理

    一.基础日期处理 //date 日期处理select current_date;select current_timestamp;//to_date(time) ;to_date(string)sel ...

  9. 大数据入门到精通10--spark rdd groupbykey的使用

    //groupbykey 一.准备数据val flights=sc.textFile("data/Flights/flights.csv")val sampleFlights=sc ...

随机推荐

  1. php连接redis服务

    $redis = new Redis(); $redis->connect('127.0.0.1', 6379);//可以执行redis操作了.....  

  2. idea常用的快捷键

    psvm,快速生存main类 快速生成main类: " public static void main(String[] args) {}",十分常用. 2 sout ,快捷生成输 ...

  3. react 点击空白处隐藏弹出层

    点击空白处隐藏弹出层的原理是:在 document 上绑定事件来隐藏弹出层,这样点击任何元素的时候都会冒泡到 document 上,都会执行隐藏弹出层的功能.然后我们在不需要隐藏弹出层的元素上阻止冒泡 ...

  4. sails.js mvc framework learning

    目的:加快开发速度,总结使用方法: menu list: custom controller custom 模块使用 custom model custom middleware custom ser ...

  5. C# Restful 启用 Session

    虽然很多人说不建议启用,但我就是想启用. [ServiceContract(SessionMode=SessionMode.Allowed)] public interface IBIService ...

  6. WIFI 802.11 a/b/g/n/ac

    802.11 a/b/g/n/ac FHSS: Frequency-hopping spread spectrum (FHSS) is a method of transmitting radio s ...

  7. Unix中共享信息方式

  8. ElasticSearch的lowlevelApi和低级别API

    之前开发使用的其实都是lowLevel的api,所谓lowlevelapi就是操作ES的json字符串要自己去写:所谓highlevel的api就是指将查询的json字符串给对象化,创建一个Searc ...

  9. C语言编程知识点

    (1)预处理指令#define 声明一个常数,用以表明1年中有多少秒(忽略闰年问题):#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL 1) #defin ...

  10. Azure VMSS (2) 对VM执行Generalize操作

    <Windows Azure Platform 系列文章目录> 在本章中,笔者将介绍如何创建Azure Template镜像模板. 1.首先,我们先创建1台Windows Server 2 ...