配置单元脚本外壳错误

xxe27gdn  于 2021-06-26  发布在  Hive
关注(0)|答案(2)|浏览(256)

我想使用shell脚本来执行一些配置单元查询。我的脚本shell是这样的:


# !/bin/bash

DST_ARCHIVE_TABLE=as400_nat_pp09_siedta_raw_dev.natart_archive
SRC_TABLE_HIVE=as400_nat_pp09_siedta_raw_dev.natart_to_process 
current_date=$(date +%Y%m%d%H%M%S)
hive -e 'SET hive.exec.dynamic.partition = true; SET hive.exec.dynamic.partition.mode = nonstrict; insert into table ${DST_ARCHIVE_TABLE} partition (to_porcess_ts) select * from ${SRC_TABLE_HIVE} where to_porcess_ts < ${current_date} '

但有个错误:

FAILED: ParseException line 1:19 cannot recognize input near 'table' '$' '{' in table name

我删除了 { 但我还是有同样的错误

j0pj023g

j0pj023g1#

使用以下方法尝试 hiveconf (举例说明):
1) 将配置单元查询移到.hql文件中。参数将通过 hiveconf .

-- query.hql
select * from ${hiveconf:MY_DB}.${hiveconf:MY_TABLE} limit 1

2) 制作一个shell脚本来设置查询的参数值,并执行它。

-- query.sh

# !/bin/bash

hive -hiveconf MY_DB=default -hiveconf MY_TABLE=my_hive_table_name -f query.hql

3) 执行它

./query.sh
gt0wga4j

gt0wga4j2#

嗨,试一下below:-

echo "SET hive.exec.dynamic.partition = true; SET hive.exec.dynamic.partition.mode = nonstrict; insert into table ${DST_ARCHIVE_TABLE} partition (to_porcess_ts) select * from ${SRC_TABLE_HIVE} where to_porcess_ts < ${current_date}" | hive -e

echo "SET hive.exec.dynamic.partition = true; SET hive.exec.dynamic.partition.mode = nonstrict; insert into table ${DST_ARCHIVE_TABLE} partition (to_porcess_ts) select * from ${SRC_TABLE_HIVE} where to_porcess_ts < ${current_date} - e" | hive

相关问题