Hive 中变量和属性命名空间

下面我们来用几个例子操作下:

&hive

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/apache-hive-2.1.0-bin/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/home/hadoop/apache-hive-2.1.0-bin/lib/hive-common-2.1.0.jar!/hive-log4j2.properties Async: true

Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
1. hive> set env:HOME;
env:HOME=/home/hadoop
this is didsplay /home/user
2. set; and set -v 这两个命令都会打印出hivevar, hiveconf, system, env的变量,但是带-v的命令会在这个的基础上打印出所有定义的属性,如: HDFS和MapReduce的属性

3. 我们可以用'Set' 命令去 为一个变量赋值,以及打印出变量值。

$hive --define foo=bar
hive> set foo;
foo=bar
hive> set hivevar:foo
    > ;
hivevar:foo=bar
hive> set hivevar:foo=bar2;
hive> set foo;
foo=bar2
hive> set hivevar:foo;
hivevar:foo=bar2

hivevar: is one optional --hivevar and --define are same

hive> create table toss1(i int, ${hivevar:foo} string);
OK
Time taken: 7.339 seconds
hive> describe toss1;
OK
i                       int                                         
bar2                    string                                      
Time taken: 1.773 seconds, Fetched: 2 row(s)
hive> create table toss2(i2 int, ${foo} string);
OK
Time taken: 0.769 seconds
hive> describe toss2;
OK
i2                      int                                         
bar2                    string                                      
Time taken: 0.463 seconds, Fetched: 2 row(s)

我们学习再学习下--hiveconf选项, Hive v0.7.*版本支持这个功能,其用于配置hive行为的所有属性。我们用它来指定Hive v0.8.0版本中增加的hive.cli.print.current.db属性。开启这个属性可以在CLI提示符打印当前所在的数据库名。默认为default.而且默认为false.

Let's learn --hiveconf optional, this function is surpported by Hive v0.7.*.

hive --hiveconf hive.cli.print.current.db=true
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/apache-hive-2.1.0-bin/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/home/hadoop/apache-hive-2.1.0-bin/lib/hive-common-2.1.0.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive (default)> set hive.cli.print.current.db;
hive.cli.print.current.db=true
hive (default)> set hiveconf:hive.cli.print.current.db;
hiveconf:hive.cli.print.current.db=true
hive (default)> set hiveconf:hive.cli.print.current.db =false;
hive> set hiveconf:hive.cli.print.current.db;
hiveconf:hive.cli.print.current.db=false

Hive 变量和属性的更多相关文章

  1. Hive之变量和属性

    首先看一下hive cli工具对于变量的定义规定的几项功能: $ bin/hive -h usage: hive -d,--define <key=value>          Vari ...

  2. runtime第二部分成员变量和属性

    接上一篇 http://www.cnblogs.com/ddavidXu/p/5912306.html 转载来源http://www.jianshu.com/p/6b905584f536 http:/ ...

  3. iOS 成员变量,实例变量,属性变量的区别,联系

    在ios第一版中: 我们为输出口同时声明了属性和底层实例变量,那时,属性是oc语言的一个新的机制,并且要求你必须声明与之对应的实例变量,例如: 注意:(这个是以前的用法) @interface MyV ...

  4. Objective-C Runtime 运行时之二:成员变量与属性

    类型编码(Type Encoding) 作为对Runtime的补充,编译器将每个方法的返回值和参数类型编码为一个字符串,并将其与方法的selector关联在一起.这种编码方案在其它情况下也是非常有用的 ...

  5. Objective-C Runtime 运行时之二:成员变量与属性(转载)

    在前面一篇文章中,我们介绍了Runtime中与类和对象相关的内容,从这章开始,我们将讨论类实现细节相关的内容,主要包括类中成员变量,属性,方法,协议与分类的实现. 本章的主要内容将聚集在Runtime ...

  6. .NET中公共变量与属性的区别

    在我们的程序中经常会出现以下的代码:  如:     成员变量     public   string   Name;     或者用属性     private   string   name    ...

  7. UNIX环境高级编程——线程同步之条件变量以及属性

    条件变量变量也是出自POSIX线程标准,另一种线程同步机制.主要用来等待某个条件的发生.可以用来同步同一进程中的各个线程.当然如果一个条件变量存放在多个进程共享的某个内存区中,那么还可以通过条件变量来 ...

  8. OC基础成员变量、属性变量、实例方法与类方法

    首先,为什么我们要定义一个新类呢?按照我的理解,就是为了抽象出来一个新的东西(也就是类),用来存储更多的数据变量和方法,一切类都直接或间接继承与NSObject. 在类的头文件里我们可以定义成员变量. ...

  9. ios -- 成员变量、实例变量与属性的区别

      最近打开手机就会被胡歌主演的<猎场>刷屏,这剧我也一直在追,剧中的郑秋冬,因为传销入狱五年,却在狱中拜得名师孙漂亮(孙红雷),苦学HR,并学习了心理学,成功收获两样法宝.出狱后因为怕受 ...

随机推荐

  1. Struts 第一天

    请简述下Struts2 的执行流程. 首先是,启动tomcat服务器,这时候会加载web.xml,当读到filter标签时,会创建过滤器对象.struts2的核心过滤器(StrutsPrepareAn ...

  2. opencv新版本的数据结构

    转自 http://blog.csdn.net/yang_xian521/article/details/7108387 记得我在OpenCV学习笔记(四)——新版本的数据结构core里面讲过新版本的 ...

  3. 51NOD1835 完全图

    传送门 分析 令f(i,j)表示i点完全图有j个联通块的方案数. 讨论有i-1个点已经固定了,我们拉出一个代表元素然后讨论它的集合大小然后组合数算一下就可以了. $$ dp(i,j) = \sum_{ ...

  4. 构建一个在线ASCII视频流服务

    构建一个在线ASCII视频流服务 2018-03-26  正常的文章 1685 什么是ASCII视频流服务? 其实这个名字是咱胡乱起的,具体叫啥我也不清楚,但效果如下: 大家可以在自己的命令行里试下, ...

  5. html+css自定义导航

    利用css来编写的导航条,先看看效果: 代码区: html: <!--导航部分--> {block name="nav"} <nav> <div cl ...

  6. STL源码剖析--迭代器(转)

    一.为什么需要traits编程技术 前面说了很多关于traits的光荣事迹,但是却一直没有介绍traits究竟是个什么东西,究竟是用来干什么的?traits在英文解释中就是特性,下面将会引入trait ...

  7. iOS CocoaPods安装与使用

    1.MAC安装Ruby环境 1>  安装RVM 控制台命令:$curl –L https://get.rvm.io | bash –s stable $source ~/.rvm/scripts ...

  8. enumerate()函数

    for index,value in enumerate(list):       print index,value 等于for i in range(0,len(list)): print i,l ...

  9. 删除表中重复id值

    DELETE t FROM (SELECT *,ROW_NUMBER()OVER(PARTITION BY test1,test2,test3,test4 ORDER BY RAND()) AS RN ...

  10. epoll简介

    1.epoll简介 epoll是I/O事件通知工具,与select/poll相比,epoll最大的好处在于它不会随着监听fd数目的增长而效率降低.epoll API既可以用作edge触发的接口,也可以 ...