如何在从文件读取的配置单元查询中传递变量作为 table 名称

How to pass variable in hive query reading from file as table name

我正在编写 shell 脚本,它将从文件中读取 table 名称,并将 table 名称传递给配置单元查询。

但我假设 $ 在 hive 中无法识别。

知道如何在配置单元查询中传递变量吗?

Error : can not recognize input near $i

#!/bin/bash

#Input file
ifile="/tmp/table.txt" 

if [[ -f "$ifile" ]]
then
  while IFS= read -r i
    hive -e "show create table $i"
  done <"$ifile"
fi

$猫table.txt

office.empoyee
office.department
office.floor

我认为这里只缺少 while 行之后的 do

if [[ -f "$ifile" ]]
then
  while IFS= read -r i
  do
    hive -e "show create table ${i}"
  done <"$ifile"
fi