https://issuetracker.google.com/issues/35905569#comment111
DECLARE v1 INT64 DEFAULT 123;
DECLARE v2 INT64 DEFAULT 123;
BEGIN
SET v1 = @v1;
SET v2 = @v2;
EXCEPTION WHEN ERROR THEN
-- nop
END;
SELECT v1, v2;
# works if all parameters are set
$ cat query_parameter.sql | bq query --nouse_legacy_sql --parameter=v1:INT64:1 --parameter=v2:INT64:2 --quiet
SELECT v1, v2; -- at [9:1]
+----+----+
| v1 | v2 |
+----+----+
| 1 | 2 |
+----+----+
# works if all parameters are not set
$ cat query_parameter.sql | bq query --nouse_legacy_sql --quiet
SELECT v1, v2; -- at [9:1]
+-----+-----+
| v1 | v2 |
+-----+-----+
| 123 | 123 |
+-----+-----+
# not works if parameters are partially set
$ cat query_parameter.sql | bq query --nouse_legacy_sql --parameter=v1:INT64:1 --quiet
Error in query string: Error processing job '{project_id}:bqjob_r14be0572274cc08e_0000018281c414ce_1': Unknown named query parameter: v2 at [1:1]