Skip to content

Instantly share code, notes, and snippets.

@JeffreyMFarley
Created February 1, 2024 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffreyMFarley/c6428ff4b241247c9a6e4f7810a57f95 to your computer and use it in GitHub Desktop.
Save JeffreyMFarley/c6428ff4b241247c9a6e4f7810a57f95 to your computer and use it in GitHub Desktop.
import random
from snowflake.snowpark.functions import trunc
def model(dbt, session):
source_df = dbt.ref("datorama_v2_temp")
campaigns = source_df[['campaign_id', 'day', 'impressions']]
campaigns = campaigns.withColumn(
'projected_five_sec_views',
trunc(campaigns['impressions'] * random.uniform(0.2, 0.5))
)
campaigns = campaigns.drop('impressions')
return campaigns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment