[英]hive script shell error
我想使用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
我刪除了{
但仍然有相同的錯誤
嗨,嘗試如下:-
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
通過使用hiveconf
嘗試以下方法(帶有示例):
1)將您的Hive查詢移到.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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.