• Hive 变量和属性


    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

  • 相关阅读:
    PyCharm专业版永久激活步骤详解(只是自己记一下以防后面需要)
    PV EV AC BAC EAC ETC等计算公式
    Linux服务器下安装Jmeter
    Python接口自动化测试运行成功但没有生成测试报告的总结
    Linux命令
    Python3+selenium环境配置
    selenium窗口切换问题
    Selenium安装问题
    Python爬虫功能(爬取网页图片)
    ASICC码对照表
  • 原文地址:https://www.cnblogs.com/Jesse-Li/p/7773628.html
Copyright © 2020-2023  润新知