#!/bin/bash
analysis_date=$1
#开始执行方法
#/opt/hive-2.3.5/bin/hive -e "select count(1) from hv_orders_user_buckets"
echo "输入的参数变量为:$analysis_date"
hive -e "use hv_user_profile;select id from hv_user_index;"
说明:使用“hive -e xxx”语句,前提是配置好hive的环境变量才能这样写。
这个语句中一定要引入 表所在数据库(use xxx)。否则,提示not found table xxx。
hive的每个sql结束的都要有“;”分号。
[www@1-11-100 opt]$ sh test.sh 2019
输入的参数变量为:2019
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive-2.3.5/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.5/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:/opt/hive-2.3.5/lib/hive-common-2.3.5.jar!/hive-log4j2.properties Async: true
OK
Time taken: 5.257 seconds
OK
id
2
1
3
Time taken: 1.692 seconds, Fetched: 3 row(s)
[www@1-11-100 opt]$
[www@1-11-100 opt]$ hive -e "use hv_user_profile;select * from hv_user_index;";
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive-2.3.5/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.5/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:/opt/hive-2.3.5/lib/hive-common-2.3.5.jar!/hive-log4j2.properties Async: true
OK
Time taken: 5.363 seconds
OK
id last_uid tb_name
2 333 hv
1 3836358 hv_users
3 444 hs
Time taken: 1.736 seconds, Fetched: 3 row(s)
[www@1-11-100 opt]$