我正在尝试构建一个以table_name作为参数的shell脚本,然后运行以下的hive查询。
INSERT OVERWRITE DIRECTORY '/data/table_name'
row format delimited
FIELDS TERMINATED BY ','
SELECT * FROM table_name
答案 0 :(得分:0)
也许你需要它:
#!/bin/bash
if [ -z "$1" ]; then exit 1; fi
printf -v TAB "%q" "$1"
/usr/bin/mysql -NBe "INSERT OVERWRITE DIRECTORY '/data/table_$TAB' row format delimited FIELDS TERMINATED BY ',' SELECT * FROM $TAB"