Ниже для BigQuery Standard SQL
#standardSQL
SELECT
userid, date, hostname,
IF(0 = COUNTIF(hostname = 'online-store.com') OVER(
PARTITION BY userid ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
), 'visitor', 'current_client') client_type
FROM `project.dataset.table`
Вы можете протестировать, поиграть с выше, используя фиктивные данные, которые вы предоставили в своем вопросе
#standardSQL
WITH `project.dataset.table` AS (
SELECT 1 userid, DATE '2018-02-01' date, 'online-store.com' hostname UNION ALL
SELECT 2, '2018-02-01', 'other' UNION ALL
SELECT 3, '2018-02-01', 'other' UNION ALL
SELECT 4, '2018-02-01', 'other' UNION ALL
SELECT 1, '2018-02-01', 'other' UNION ALL
SELECT 1, '2018-04-07', 'other' UNION ALL
SELECT 4, '2018-04-08', 'online-store.com' UNION ALL
SELECT 5, '2018-04-08', 'other' UNION ALL
SELECT 6, '2018-04-08', 'other' UNION ALL
SELECT 4, '2018-04-08', 'other' UNION ALL
SELECT 8, '2018-04-08', 'other' UNION ALL
SELECT 1, '2018-07-07', 'other' UNION ALL
SELECT 1, '2018-11-22', 'online-store.com'
)
SELECT
userid, date, hostname,
IF(0 = COUNTIF(hostname = 'online-store.com') OVER(
PARTITION BY userid ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
), 'visitor', 'current_client') client_type
FROM `project.dataset.table`
ORDER BY date
с результатом
Row userid date hostname client_type
1 1 2018-02-01 online-store.com current_client
2 1 2018-02-01 other current_client
3 2 2018-02-01 other visitor
4 3 2018-02-01 other visitor
5 4 2018-02-01 other visitor
6 1 2018-04-07 other current_client
7 4 2018-04-08 online-store.com current_client
8 4 2018-04-08 other current_client
9 5 2018-04-08 other visitor
10 6 2018-04-08 other visitor
11 8 2018-04-08 other visitor
12 1 2018-07-07 other current_client
13 1 2018-11-22 online-store.com current_client