#creating tables with schema only:
for f in $list;
do
echo "event name :::::$f"
bq query --use_legacy_sql=False --destination_table dataset_name.$f 'select * from `project_id.dataset_name.$f` where 1=2'
done
查询语句未将$f
视为select语句中的参数。
答案 0 :(得分:1)
由于刻度[']而发生。
这里有一个工作代码(我用数字):
for i in {1..3}
do
echo "TABLE $i"
bq query --use_legacy_sql=false 'select * from `<project>.<database>.'$i'`'
done
了解如何用勾号[']分隔参数$i
。对于您的情况,应为:
bq query --use_legacy_sql=False --destination_table dataset_name.$f 'select * from `project_id.dataset_name.'$f'` where 1=2'