I am trying to query my data in big query and want to avoid null records but keep getting them.
Here is my query so far:
select
(SELECT x.value FROM UNNEST(user_properties) x
WHERE x.key='restaurantName'
and x.value is not null).string_value as restaurantName ,
(SELECT x.value FROM UNNEST(user_properties) x
WHERE x.key='restaurantId' and x.value is not null).string_value as
restaurantID ,
(SELECT x.value FROM UNNEST(user_properties) x
WHERE x.key='user_id' and x.value is not null).string_value as user
FROM some_data_set where event_name="ConfirmOrderBtn" and event_date between
'20191110' and '_*' and app_info.id = "app_id"
Here are my query results:
Below is for BigQuery Standard SQL
#standardSQL
SELECT * FROM (
SELECT
(SELECT x.value
FROM UNNEST(user_properties) x
WHERE x.key='restaurantName'
AND x.value IS NOT NULL
).string_value AS restaurantName ,
(SELECT x.value
FROM UNNEST(user_properties) x
WHERE x.key='restaurantId'
AND x.value IS NOT NULL
).string_value AS restaurantID ,
(SELECT x.value
FROM UNNEST(user_properties) x
WHERE x.key='user_id'
AND x.value IS NOT NULL
).string_value AS user
FROM `project.dataset.some_data_set`
WHERE event_name="ConfirmOrderBtn"
AND event_date BETWEEN '20191110' AND '_*'
AND app_info.id = "app_id"
)
WHERE NOT (restaurantName IS NULL OR restaurantID IS NULL OR user IS NULL)