impala学习

1impala原理

2impala类型转换

2、cast函数

    cast(expr AS type), 类型转换函数, 比如将number转成string, 或相反. 

    select cast(length as int) len from dw_bill_his where length != '无' and startdate='2018-09-01' order by cast(length as int);

 

3impala分页查询

[localhost:21000] > create table numbers (x int);
[localhost:21000] > insert into numbers select x from very_long_sequence;
Inserted 1000000 rows in 1.34s
[localhost:21000] > select x from numbers order by x limit 5 offset 0;
+----+
| x  |
+----+
| 1  |
| 2  |
| 3  |
| 4  |
| 5  |
+----+
Returned 5 row(s) in 0.26s
[localhost:21000] > select x from numbers order by x limit 5 offset 5;
+----+
| x  |
+----+
| 6  |
| 7  |
| 8  |
| 9  |
| 10 |
+----+
Returned 5 row(s) in 0.23s

自己踩坑:分页排序的时候没有order by多字段,造成分页查询字段多

4----20190808相互转换2019-08-08

select cast(concat(substr('20190808',1,4),'-',substr('20190808',5,2),'-',substr('20190808',7,2)) as String) from table1
select regexp_replace(substr('2019-08-08',1,10),'-','') from table1 

5大小写转换

--使用lower返回全小写的hello world
[master:21000] > select lower('Hello World') as lower;
+-------------+
| lower       |
+-------------+
| hello world |
+-------------+
--使用lcase返回全小写的hello world
[master:21000] > select lcase('Hello World') as lcase;
+-------------+
| lcase       |
+-------------+
| hello world |
--使用upper返回全小写的hello world
[master:21000] > select upper('hello world') as upper;
+-------------+
| upper       |
+-------------+
| HELLO WORLD |
+-------------+
--使用ucase返回全小写的hello world
[master:21000] > select ucase('hello world') as ucase;
+-------------+
| ucase       |
+-------------+
| HELLO WORLD |
+-------------+

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值