【发布时间】:2025-11-26 13:10:02
【问题描述】:
我正在尝试将日期列表作为参数传递给我的配置单元查询。
#!/bin/bash
echo "Executing the hive query - Get distinct dates"
var=`hive -S -e "select distinct substr(Transaction_date,0,10) from test_dev_db.TransactionUpdateTable;"`
echo $var
echo "Executing the hive query - Get the parition data"
hive -hiveconf paritionvalue=$var -e 'SELECT Product FROM test_dev_db.TransactionMainHistoryTable where tran_date in("${hiveconf:paritionvalue}");'
echo "Hive query - ends"
输出为:
Executing the hive query - Get distinct dates
2009-02-01 2009-04-01
Executing the hive query - Get the parition data
Logging initialized using configuration in file:/hive/conf/hive-log4j.properties
OK
Product1
Product1
Product1
Product1
Product1
Product1
Time taken: 0.523 seconds, Fetched: 6 row(s)
Hive query - ends
它只将第一个日期作为输入。我想将我的日期传递为 ('2009-02-01','2009-04-01') 注意:TransactionMainHistoryTable 以字符串类型在 tran_date 列上进行分区。
【问题讨论】:
-
在您的选择查询本身中制作您想要的输出。在您的第一个 select 语句中添加引号和逗号。
-
有没有办法使用shell创建列表或数组?
标签: shell hive parameters hiveql hadoop-partitioning