1

Can I ask how to write the correct query for UNION in Big Query.

For example, Table A = has some columns which the data type is not string.

enter image description here

Table B = No such columns in the picture above.

Can someone help to write the correct query

John
  • 17
  • 2

1 Answers1

0

Try explicitly specifying null values:

with table_a as (
  select 'from table a' as src, current_datetime() as datetime_column, 1.5 as float_column, 3 as integer_column
),
table_b as (
  select 'from table b' as src
)
select * from table_a
union all
select src, null, null, null from table_b

enter image description here

Sergey Geron
  • 9,098
  • 2
  • 22
  • 29