Last active
July 12, 2017 18:28
-
-
Save moacirmoda/1897428715fbcdba7a8b9c1352e86899 to your computer and use it in GitHub Desktop.
Poder do Peewee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emails = FactEmailMovement.select(FactEmailMovement, FactEmail, DimEmailAddress) \ | |
.join(FactEmail) \ | |
.join(FactDebtor) \ | |
.join(DimDocument) \ | |
.switch(FactEmail) \ | |
.join(DimEmailAddress) \ | |
.where(DimDocument.document == '12532825600') | |
""" | |
SELECT | |
`t1`.`id_email_movement`, `t1`.`active`, `t1`.`best_email`, `t1`.`complaint_score`, `t1`.`cpc`, `t1`.`cpe`, | |
`t1`.`created_at`, `t1`.`created_at_date_id`, `t1`.`created_at_time_id`, `t1`.`delivery_score`, | |
`t1`.`email_movement_all_columns_hash`, `t1`.`hard_bounce`, `t1`.`id_channel`, `t1`.`id_debtor`, `t1`.`id_document`, | |
`t1`.`id_document_enrichment`, `t1`.`id_email`, `t1`.`id_opt_out_provider`, `t1`.`id_status_contact`, `t1`.`id_user`, | |
`t1`.`is_valid`, `t1`.`opt_out`, `t1`.`opt_out_reason`, `t1`.`score_enrichment`, `t1`.`soft_bounce`, `t1`.`updated_at`, | |
`t1`.`updated_at_date_id`, `t1`.`updated_at_time_id`, `t2`.`id_email`, `t2`.`created_at`, `t2`.`created_at_date_id`, | |
`t2`.`created_at_time_id`, `t2`.`email_all_columns_hash`, `t2`.`id_debtor`, `t2`.`id_document`, `t2`.`id_domain`, | |
`t2`.`id_email_address`, `t2`.`id_user`, `t2`.`updated_at`, `t2`.`updated_at_date_id`, `t2`.`updated_at_time_id`, | |
`t4`.`id_email_address`, `t4`.`email`, `t4`.`email_hash`, `t4`.`id_domain`, `t4`.`type` | |
FROM `fact_email_movement` AS t1 | |
INNER JOIN `fact_email` AS t2 ON (`t1`.`id_email` = `t2`.`id_email`) | |
INNER JOIN `fact_debtor` AS t3 ON (`t2`.`id_debtor` = `t3`.`id_debtor`) | |
INNER JOIN `dim_email_address` AS t4 ON (`t2`.`id_email_address` = `t4`.`id_email_address`) | |
INNER JOIN `dim_document` AS t5 ON (`t3`.`id_document` = `t5`.`id_document`) | |
WHERE | |
(`t5`.`document` = %s) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment