Create v_order_emails (#360)

This commit is contained in:
Fredrik Ringqvist
2023-11-29 09:53:29 +01:00
committed by GitHub
parent eaf0fef362
commit 1fc90598a2
+20
View File
@@ -0,0 +1,20 @@
DROP VIEW IF EXISTS v_order_emails;
CREATE VIEW v_order_emails AS
select
orders.id order_id,
orders.inserted::date order_date,
billing.email billing_email,
billing.first_name billing_firstname,
billing.last_name billing_lastname
from
orders
left join addresses billing on billing_address_id = billing.id
where
orders.paid = 1
;
-- If we want to read this with direct access from BigQuery to Postgres:
-- CREATE USER bigquery WITH PASSWORD 'secret';
-- GRANT SELECT ON v_order_emails TO bigquery;
-- GRANT USAGE ON SCHEMA public TO bigquery;
-- We don't need this now as we will access the view ourselves instead and get the results to BigQuery via S3.