By design, Dataproc's embedded queries are inteded to work the same as "pig -e" or "pig -execute", vs having queryFileUri being the same as "pig -f", since people may depend on various subtle differences in how Pig handles the two.
Unfortunately, this means we also inherit behavioral differences which may be seen as bugs, like in this case. I'd say it should be considered a bug in Pig, and that parameter substitution *ought* to work with inline queries the same way as they work with query files.
My lightweight repro which shows in both "gcloud dataproc" and in directly running pig:
# Fails
gcloud dataproc jobs submit pig --cluster dhuo-new --params filename=file:///etc/pig/conf/log4j.properties.template --execute "a = load '\${filename}'
# Works
echo "a = load '\${filename}'; dump a;" > test.pig; gcloud dataproc jobs submit pig --cluster dhuo-new --params filename=file:///etc/pig/conf/log4j.properties.template --file test.pig
Looking at the code, they only call runParamPreprocessor inside the "case FILE:" block, and there's no equivalent in the "case STRING:" block:
Possibly because the helper function seems to assume a file and does parameter substitution by creating a new substituted file, from what I can tell.
In this case you could file a JIRA if one doesn't already exist tracking this in Pig upstream, or possibly someone from Google can do it if we have some time to diagnose it with more certainty, and then if we can get a patch submitted upstream, it can be backported in a future Dataproc version.