Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery - cannot UNION String and NULL

I have two tables that I am trying to UNION. Column id in table1 is of type STRING. I do not have that column in table2 so I am writing SELECT NULL AS id FROM table2 but BigQuery thinks that column id in table2 is of type INT64.

I get this error - Column 2 in UNION ALL has incompatible types: STRING, INT64.

Query works if I write SELECT "" AS id FROM table2 instead.

like image 944
Kakaji Avatar asked Feb 01 '18 08:02

Kakaji


Video Answer


1 Answers

SELECT id FROM table1 UNION ALL SELECT CAST(NULL AS STRING) FROM table2

like image 108
Melissa Guo Avatar answered Sep 17 '22 12:09

Melissa Guo