6.  insert 语句

1) 因为目标表有partition, 所以刚开始我使用的语句是

insert overwrite table sa_r_item_sales_day_week_month partition(part=FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd'))
select ...

然而报错:

Error while compiling statement: FAILED: ParseException cannot recognize input near 'FROM_UNIXTIME' '(' 'UNIX_TIMESTAMP' in constant

原因: 语法不对

2) 正确语法:

insert overwrite table sa_r_item_sales_day_week_month partition(part='2015-12-17')

或者 

 insert overwrite table sa_r_item_sales_day_week_month partition(part='${part}')      --part就是你穿进去的参数

??

变量在哪赋值或声明 尚不清楚

7. datetime 并没有这个类型

time

FROM_UNIXTIME(UNIX_TIMESTAMP()) 可以获得现在的年月日时分秒;

2016-01-21 10:41:26

CURRENT_DATE 和 CURRENT_TIMESTAMP

8.  分号字符

分号是SQL语句结束标记,在HiveQL中也是,但是在HiveQL中,对分号的识别没有那么智慧,例如:
           select concat(key,concat(';',key)) from dual;
但HiveQL在解析语句时提示:
          FAILED: Parse Error: line 0:-1 mismatched input '<EOF>' expecting ) in function specification
解决的办法是,使用分号的八进制的ASCII码进行转义,那么上述语句应写成:
select concat(key,concat('\073',key)) from dual;

9. hive文件上传后,中文显示为乱码

因为hive的数据是保存在HDFS里的,所以保存文件时,选择UTF8即可。

10. Hive 删除列

alter table product replace columns(name string);

--  原列为id, name

-- 会把列往前移动,前面的列被抹掉,但文件格式不变,只是不显示

11. impala 和hive 相通,impala是计算引擎

1)invalidate metadata;

  • 如果在hive里面做了新增、删除数据库、表或者数据等更新操作,需要执行在impala里面执行此命令,才能将hive的数据同步impala;
  • 如果直接在impala里面新增、删除数据库、表或者数据,会自动同步到hive,无需执行任何命令。

2)impala sql 只能写insert into,不能overwrite

hive 使用笔记(partition; HDFS乱码;日期函数)的更多相关文章

  1. hive学习笔记之七:内置函数

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  2. hive 使用笔记(partition; HDFS乱码)

    6.  insert 语句 1) 因为目标表有partition, 所以刚开始我使用的语句是 insert overwrite table sa_r_item_sales_day_week_month ...

  3. hive日期函数

    今天select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') UNIX时间戳转日期函数: from_unixtime 语法: from_ ...

  4. hive函数总结-日期函数

    获取当前UNIX时间戳函数: unix_timestamp语法: unix_timestamp() 返回值: bigint说明: 获得当前时区的UNIX时间戳举例: hive> select u ...

  5. Hive入门笔记---2.hive函数大全

    Hive函数大全–完整版 现在虽然有很多SQL ON Hadoop的解决方案,像Spark SQL.Impala.Presto等等,但就目前来看,在基于Hadoop的大数据分析平台.数据仓库中,Hiv ...

  6. Hive中日期函数总结

    --Hive中日期函数总结: --1.时间戳函数 --日期转时间戳:从1970-01-01 00:00:00 UTC到指定时间的秒数 select unix_timestamp(); --获得当前时区 ...

  7. Hive的日期函数

    1.unix时间戳转时间函数 语法: from_unixtime(bigint unixtime[, string format]) 返回值: string 说明: 转化UNIX时间戳(从1970-0 ...

  8. hive日期函数-原生函数(二)

    1. from_unixtime 日期函数UNIX时间戳转日期函数: from_unixtime 语法:from_unixtime(bigint unixtime[, stringformat]) 返 ...

  9. 【hive 日期函数】Hive常用日期函数整理

    1.to_date:日期时间转日期函数 select to_date('2015-04-02 13:34:12');输出:2015-04-02122.from_unixtime:转化unix时间戳到当 ...

随机推荐

  1. POJ 2585:Window Pains(拓扑排序)

    Window Pains Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2524   Accepted: 1284 Desc ...

  2. OJ链接

    BNU..好难找..http://www.bnuoj.com

  3. Makefile在内核编译中的使用

    1.一个配置选项选中多个文件 path:drivers/media/i2c/adv748x adv748x-objs := \ adv748x-afe.o \ adv748x-core.o \ adv ...

  4. dbt 基本试用

    dbt 是一个很不错的进行etl 中的t 处理的工具,灵活简单,我们需要写的就是select 语句 dbt 帮助我们进行处理 测试集成了graphql 以及使用docker 运行 安装 pip ins ...

  5. php header运用细节

    http://www.111cn.net/phper/php-function/55872.htm http://blog.sina.com.cn/s/blog_7298f36f01011dxv.ht ...

  6. REST与RESTFul API最佳实践

    我经常会面试一些做PHP的开发者,让我很奇怪的是,10个人总有8个多不知道什么是REST服务,甚至是没有听说过.但RESTFul API已经是现在互联网里对外开放接口的主流模式,可参考: 豆瓣API  ...

  7. FastAdmin 教程草稿大纲

    FastAdmin 教程草稿大纲 计划 FastAdmin 教程大纲 FastAdmin 环境搭建 phpStudy 2018 安装 一键 CRUD 教程 环境变量配置 环境安装 命令行安装 列出所需 ...

  8. JUC集合之 ConcurrentSkipListMap

    ConcurrentSkipListMap介绍 ConcurrentSkipListMap是线程安全的有序的哈希表,适用于高并发的场景. ConcurrentSkipListMap和TreeMap,它 ...

  9. HBase常用指令

    disable 'smsFlow'drop 'smsFlow'create 'smsFlow','info','partition'count 'smsFlow'scan 'smsFlow' trun ...

  10. Angular 4 管道

    一.date管道 1.html 2. 控制器中的定义brithday 3.效果图 如果时间格式 为: 我的生日是{{birthday | date:'yyyy-MM-dd HH:mm:ss'}} 则效 ...