美文网首页互联网科技
HIVE初步(二):基本操作

HIVE初步(二):基本操作

作者: 迷糊的小竹笋 | 来源:发表于2019-04-02 16:24 被阅读1次
shell命令
hive -h
usage: hive
 -e <quoted-query-string>         SQL from command line
 -f <filename>                    SQL from files
 -h,--help                        Print help information
    --hiveconf <property=value>   Use value for given property
 -i <filename>                    Initialization SQL file
 -S,--silent                      Silent mode in interactive shell
 -v,--verbose                     Verbose mode (echo executed SQL to the
                                  console)
eg:
hive -e "show databases;"
参数配置

主要配置:
https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties
1.hive主要配置文件(作用域:所有任务):
hive-default.xml:默认配置文件
hive-site.xml:用户配置文件,其中的配置项会将hive-default.xml中的配置覆盖掉
2.通过命令行中配置(作用域:此次操作,即session)

bin/hive -hiveconf hive.root.logger=INFO, console

3.通过HQL配置(作用域:此session)

set mapred.reduce.tasks=100;
函数

1.内置函数
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-StringOperators
2.自定义函数(UDF)
可以理解成,在逻辑较复杂的情况下,可以用其他方式(eg:python)替代HQL去处理数据。
如,有一个数据表person_tb在person.txt中,我们可以通过复杂的select操作对数据进行筛选处理,也可以通过一个cat person.txt|python deal.py得到目标数据(deal.py即为UDF)。在hive中执行这个UDF,需要借助transform。
a.首先需要通过 ADD FILE 指令添加至 Hive 中进行注册
b.用transform ... as ...进行调用

hive > ADD FILE deal.py
hive > SELECT TRANSFORM (<columns>)
USING 'python deal.py'
AS (<columns>)
FROM person_tb;

相关文章

  • HIVE初步(二):基本操作

    shell命令 参数配置 主要配置:https://cwiki.apache.org/confluence/dis...

  • hive基本操作之二

    1.查找数据到本地 insert overwrite local directory '/home/mydir/...

  • HIVE

    基本操作 hive进入hive模式 exit; 退出hive模式 展示正则匹配表名hive> use ad_s...

  • Hive之同比环比的计算

    Hive系列文章 Hive表的基本操作[http://www.ikeguang.com/?p=1657] Hive...

  • Hive sql常见操作

    基本sql操作 hive表操作 分区操作 Hive内置函数 (1)数学函数 常用的数学函数都有:round、flo...

  • Hive 基本操作

    准备工作 1.检查各项服务是否已正常启动 [x] hdfs启动【start-dfs.sh】 [x] yarn启动【...

  • Hive 基本操作

    数据库基本操作 ( 和MySQL脚本相似 ): 创建删除库操作 创建删除表操作 hive 特点 Hive不支持修改...

  • Hive基本操作

    在所有操作前先启动hdfs、yarn、historyserver。 hive操作 启动hivebin/hive 创...

  • Hive基本操作

    参考:hive 表的常用操作Hive基本操作 1 Thrift Server Thrift 支持多种语言之间的RP...

  • Hive基本操作

    1.使用SQL文件创建一张表: hive -f create_table 2.将外部数据加载到一张表里面: LOA...

网友评论

    本文标题:HIVE初步(二):基本操作

    本文链接:https://www.haomeiwen.com/subject/wpmbbqtx.html