如何在Google BigQuery Composer及Cloud Shell中提交多查询语句
I’ve run into this exact issue before when working with Query Composer and Google Cloud Shell—they’re pretty strict about single-statement submissions by default, even for straightforward operations like DROP TABLE. Here’s how to get around that error:
Run statements one at a time
The quickest fix is to split your multipleDROPcommands into individual submissions. ExecuteDROP TABLE your_table_name;first, wait for it to complete, then run the next one. It’s a bit more manual, but it avoids the parsing error entirely.Batch execute via a SQL script file
If you’ve got a bunch of tables to drop, save all your statements into a.sqlfile (let’s call itcleanup_tables.sql) like this:DROP TABLE table_1; DROP TABLE table_2; DROP TABLE table_3;Then in Cloud Shell, use the appropriate command to run the entire file. For BigQuery, that would be:
bq query --use_legacy_sql=false < cleanup_tables.sqlThis method lets you run all your statements in one go without triggering the unexpected input error.
Switch to a multi-statement-friendly editor
If you regularly need to run multiple statements, consider using a tool that supports this natively. For example, the BigQuery Studio editor (distinct from Query Composer) handles semicolon-separated statements correctly, as do most local SQL clients that connect to your database.
A quick heads-up: Always double-check the tables you’re dropping before executing these commands—no one wants to accidentally delete critical data!
内容的提问来源于stack exchange,提问作者loct

