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. Python 网络爬虫 008 (编程) 通过ID索引号遍历目标网页里链接的所有网页

    通过 ID索引号 遍历目标网页里链接的所有网页 使用的系统:Windows 10 64位 Python 语言版本:Python 2.7.10 V 使用的编程 Python 的集成开发环境:PyChar ...

  2. php学习笔记-定义数组和引用数组元素

    上图包含两种定义数组的方法,一种是通过数组索引来创建的,一种是通过array()函数来创建的.

  3. java中字符串的存储

    在java中,不同的字符串赋值方法,其所在的地址可能不同也就导致,两个字符串的值看似相等可是在s1==s2操作时,其结果返回的却是false 例: String s1 = "Programm ...

  4. parseXXX的用法

    转换字符串. parseXXX是Integer类.等基本数据类型包装类的方法,用于实现String和int型数据的转换.例如, Integer.getInteger(String s) 从字符串中获取 ...

  5. Entity Framework Tutorial Basics(25):Delete Single Entity

    Delete Entity using DBContext in Disconnected Scenario: We used the Entry() method of DbContext to m ...

  6. Entity Framework Code-First(23):Entity Framework Power Tools

    Entity Framework Power Tools: Entity Framework Power Tools (currently in beta 3) has been released. ...

  7. java全栈day06---数组的练习 冒泡排序

    水仙花练习功能实现 * A: 水仙花练习功能实现 * a: 题目分析 * 明确什么样的数就是水仙花数.水仙花数是指一个3位数(100-999之间),其每位数字立方之和等于该3位数本身. 如153 = ...

  8. Sql Server 判断表是否存在方法

    在创建表之前,通常需要先判断该表是否已经存在,如果存在则不需要创建:有时候删除表之前也需要先行判断是否存在,否则会报错. 判断方法大致有以下两种: 方法一: from sysObjects where ...

  9. Gazebo学习随记5 杂记

    模拟建筑编辑器 将卫星图导入世界,方便空中机器人模拟 录像和回放 记录筛选 给关节添加力/扭矩  一开始不知道哪里出现了偏差以一动不动,重启就好了 HDF5数据集 代码内省 模型插件   !!!我终于 ...

  10. angular原理及模块简介

    Angular简介(大神可略过) Angular是一个强大的前端框架,其强大之处主要是可以把静态页面与动态数据绑定起来.平时我们看到的网页界面上面的数据都是固定,但如果我们要变化这些数据,例如我在一个 ...