BigQuery Syntax error: Expected keyword ALL or keyword DISTINCT but got keyword SELECT

Problem 🔍

UNION Keyword is not supported in Bigquery

KeywordBigQuery Equivalent
UNIONUNION DISTINCT
UNION ALLUNION ALL

Solution 💡

Replace UNION Keyword with UNION DISTINCT

Example: Rewrite the below query,

SELECT * FROM Sales_Asia UNION SELECT * from Sales_Europe;

to

SELECT * FROM Sales_Asia UNION DISTINCT SELECT * from Sales_Europe;

This should fix the issue !

mCollins

posted on 20 Feb 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds