<jupyter_start><jupyter_text>1. Install DependenciesFirst install the libraries needed to execute recipes, this only needs to be done once, then click play.<jupyter_code>!pip install git+https://github.com/google/starthinker<jupyter_output><empty_output><jupyter_text>2. Get Cloud Project IDTo run this recipe [requires a Google Cloud Project](https://github.com/google/starthinker/blob/master/tutorials/cloud_project.md), this only needs to be done once, then click play.<jupyter_code>CLOUD_PROJECT = 'PASTE PROJECT ID HERE'

print("Cloud Project Set To: %s" % CLOUD_PROJECT)<jupyter_output><empty_output><jupyter_text>3. Get Client CredentialsTo read and write to various endpoints requires [downloading client credentials](https://github.com/google/starthinker/blob/master/tutorials/cloud_client_installed.md), this only needs to be done once, then click play.<jupyter_code>CLIENT_CREDENTIALS = 'PASTE CREDENTIALS HERE'

print("Client Credentials Set To: %s" % CLIENT_CREDENTIALS)<jupyter_output><empty_output><jupyter_text>4. Enter Browser Activity Dashboard ( 2019 ) ParametersVisualizes a client's Campaign Manager and DV360 activity by browser and device 1. Wait for BigQuery->StarThinker Data->UNDEFINED->* to be created. 1. Join the StarThinker Assets Group to access the following assets 1. For each of the following copy and connect to the new BigQuery sources above. See detailed instructions. 1. Copy Combined_Browser_Delivery. 1. Copy DV360_Browser_Delivery. 1. Copy CM_Browser_Delivery. 1. Copy Floodlight_Browser_Delivery. 1. Copy Browser Delivery Report. 1. When prompted choose the new data sources you just created. 1. Or give these intructions to the client.Modify the values below for your use case, can be done multiple times, then click play.<jupyter_code>FIELDS = {
  'dataset': '',  # Place where tables will be written in BigQuery.
  'dcm_account': '',  # DCM account id of client.
  'dcm_advertisers': '',  # Comma delimited list of DCM advertiser ids.
  'dcm_floodlight': '',  # DCM floodlight configuration id.
  'dbm_partner': '',  # DBM partner id.
  'dbm_advertisers': '',  # Comma delimited list of DBM advertiser ids.
}

print("Parameters Set To: %s" % FIELDS)<jupyter_output><empty_output><jupyter_text>5. Execute Browser Activity Dashboard ( 2019 )This does NOT need to be modified unles you are changing the recipe, click play.<jupyter_code>from starthinker.util.project import project
from starthinker.script.parse import json_set_fields

USER_CREDENTIALS = '/content/user.json'

TASKS = [
  {
    'dataset': {
      'auth': 'user',
      'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'Report suffix and BigQuery dataset to contain data.'}}
    }
  },
  {
    'dcm': {
      'auth': 'user',
      'report': {
        'account': {'field': {'name': 'dcm_account','kind': 'integer','order': 2,'default': '','description': 'DCM account id of client.'}},
        'filters': {
          'dfa:advertiser': {
            'values': {'field': {'name': 'dcm_advertisers','kind': 'integer_list','order': 3,'default': '','description': 'Comma delimited list of DCM advertiser ids.'}}
          }
        },
        'body': {
          'type': 'STANDARD',
          'format': 'CSV',
          'name': {'field': {'name': 'dataset','kind': 'string','prefix': 'CM_Browser_Delivery_','description': 'Report in DCM, should be unique.'}},
          'accountId': {'field': {'name': 'dcm_account','kind': 'integer','order': 2,'default': '','description': 'DCM account id of client.'}},
          'criteria': {
            'dateRange': {
              'relativeDateRange': 'LAST_365_DAYS'
            },
            'dimensions': [
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:advertiser'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:advertiserId'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:campaign'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:campaignId'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:site'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:browserPlatform'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:platformType'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:date'
              }
            ],
            'metricNames': [
              'dfa:impressions',
              'dfa:clicks',
              'dfa:activityViewThroughConversions',
              'dfa:activityClickThroughConversions'
            ]
          }
        }
      }
    }
  },
  {
    'dcm': {
      'auth': 'user',
      'report': {
        'account': {'field': {'name': 'dcm_account','kind': 'integer','order': 2,'default': '','description': 'DCM account id of client.'}},
        'name': {'field': {'name': 'dataset','kind': 'string','prefix': 'CM_Browser_Delivery_','description': 'Report in DCM, should be unique.'}}
      },
      'out': {
        'bigquery': {
          'table': 'CM_Browser_Delivery',
          'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'BigQuery dataset to contain data.'}}
        }
      }
    }
  },
  {
    'dcm': {
      'auth': 'user',
      'report': {
        'account': {'field': {'name': 'dcm_account','kind': 'integer','order': 2,'default': '','description': 'DCM account id of client.'}},
        'body': {
          'name': {'field': {'name': 'dataset','kind': 'string','prefix': 'CM_Browser_Floodlight_','description': 'Report in DCM, should be unique.'}},
          'type': 'FLOODLIGHT',
          'format': 'CSV',
          'accountId': {'field': {'name': 'dcm_account','kind': 'integer','order': 2,'default': '','description': 'DCM account id of client.'}},
          'floodlightCriteria': {
            'dateRange': {
              'relativeDateRange': 'LAST_60_DAYS'
            },
            'dimensions': [
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:advertiser'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:advertiserId'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:campaign'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:campaignId'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:date'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:browserPlatform'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:platformType'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:activity'
              },
              {
                'kind': 'dfareporting#sortedDimension',
                'name': 'dfa:activityId'
              }
            ],
            'floodlightConfigId': {
              'dimensionName': 'dfa:floodlightConfigId',
              'kind': 'dfareporting#dimensionValue',
              'matchType': 'EXACT',
              'value': {'field': {'name': 'dcm_floodlight','kind': 'integer','order': 4,'default': '','description': 'DCM floodlight configuration id.'}}
            },
            'metricNames': [
              'dfa:activityClickThroughConversions',
              'dfa:activityViewThroughConversions',
              'dfa:totalConversions'
            ],
            'reportProperties': {
              'includeUnattributedCookieConversions': True,
              'includeUnattributedIPConversions': False
            }
          }
        }
      }
    }
  },
  {
    'dcm': {
      'auth': 'user',
      'report': {
        'account': {'field': {'name': 'dcm_account','kind': 'integer','order': 2,'default': '','description': 'DCM account id of client.'}},
        'name': {'field': {'name': 'dataset','kind': 'string','prefix': 'CM_Browser_Floodlight_','description': 'Report in DCM, should be unique.'}}
      },
      'out': {
        'bigquery': {
          'table': 'CM_Browser_Floodlight',
          'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'BigQuery dataset to contain data.'}}
        }
      }
    }
  },
  {
    'dbm': {
      'auth': 'user',
      'report': {
        'name': {'field': {'name': 'dataset','kind': 'string','prefix': 'DV360_Browser_Delivery_','description': 'DBM report name, should be unique.'}},
        'body': {
          'timezoneCode': 'America/Los_Angeles',
          'metadata': {
            'title': {'field': {'name': 'dataset','kind': 'string','prefix': 'DV360_Browser_Delivery_','description': 'Name of report in DBM, should be unique.'}},
            'dataRange': 'LAST_365_DAYS'
          },
          'params': {
            'type': 'TYPE_GENERAL',
            'includeInviteData': True,
            'filters': [
              {
                'type': 'FILTER_PARTNER',
                'value': {'field': {'name': 'dbm_partner','kind': 'integer','order': 5,'default': '','description': 'DBM partner id.'}}
              },
              {
                'type': 'FILTER_ADVERTISER',
                'value': {'field': {'name': 'dbm_advertisers','kind': 'integer_list','order': 6,'default': '','description': 'Comma delimited list of DBM advertiser ids.'}}
              }
            ],
            'groupBys': [
              'FILTER_ADVERTISER',
              'FILTER_BROWSER',
              'FILTER_MEDIA_PLAN',
              'FILTER_DATE',
              'FILTER_DEVICE_TYPE',
              'FILTER_INSERTION_ORDER',
              'FILTER_PAGE_LAYOUT'
            ],
            'metrics': [
              'METRIC_IMPRESSIONS',
              'METRIC_CLICKS',
              'METRIC_LAST_CLICKS',
              'METRIC_LAST_IMPRESSIONS',
              'METRIC_REVENUE_ADVERTISER',
              'METRIC_MEDIA_COST_ADVERTISER'
            ]
          }
        }
      }
    }
  },
  {
    'dbm': {
      'auth': 'user',
      'datastudio': True,
      'report': {
        'name': {'field': {'name': 'dataset','kind': 'string','prefix': 'DV360_Browser_Delivery_','description': 'DBM report name, should be unique.'}}
      },
      'out': {
        'bigquery': {
          'table': 'DV360_Browser_Delivery',
          'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'BigQuery dataset to contain data.'}},
          'schema': [
            {
              'name': 'Advertiser',
              'type': 'STRING'
            },
            {
              'name': 'Advertiser_ID',
              'type': 'INTEGER'
            },
            {
              'name': 'Advertiser_Status',
              'type': 'STRING'
            },
            {
              'name': 'Advertiser_Integration_Code',
              'type': 'STRING'
            },
            {
              'name': 'Browser',
              'type': 'STRING'
            },
            {
              'name': 'Campaign',
              'type': 'STRING'
            },
            {
              'name': 'Campaign_ID',
              'type': 'INTEGER'
            },
            {
              'name': 'Report_Day',
              'type': 'DATE'
            },
            {
              'name': 'Device_Type',
              'type': 'STRING'
            },
            {
              'name': 'Insertion_Order',
              'type': 'STRING'
            },
            {
              'name': 'Insertion_Order_ID',
              'type': 'INTEGER'
            },
            {
              'name': 'Insertion_Order_Status',
              'type': 'STRING'
            },
            {
              'name': 'Insertion_Order_Integration_Code',
              'type': 'STRING'
            },
            {
              'name': 'Environment',
              'type': 'STRING'
            },
            {
              'name': 'Advertiser_Currency',
              'type': 'STRING'
            },
            {
              'name': 'Impressions',
              'type': 'INTEGER'
            },
            {
              'name': 'Clicks',
              'type': 'INTEGER'
            },
            {
              'name': 'Post_Click_Conversions',
              'type': 'FLOAT'
            },
            {
              'name': 'Post_View_Conversions',
              'type': 'FLOAT'
            },
            {
              'name': 'Revenue_Adv_Currency',
              'type': 'FLOAT'
            },
            {
              'name': 'Media_Cost_Advertiser_Currency',
              'type': 'FLOAT'
            }
          ]
        }
      }
    }
  },
  {
    'bigquery': {
      'auth': 'user',
      'to': {
        'table': 'Floodlight_Browser_Delivery',
        'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'BigQuery dataset to contain data.'}}
      },
      'from': {
        'query': 'WITH\r\nbrowser_clean AS (\r\n  SELECT\r\n    Advertiser,\r\n    Advertiser_Id,\r\n    Campaign,\r\n    Campaign_Id,\r\n    Browser_Platform,\r\n   Activity,\r\n    Activity_ID,\r\n    CASE\r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*Chrome).*") THEN "Chrome" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*Firefox).*") THEN "Firefox" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*Safari).*") THEN "Safari"\r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*iPad).*") THEN "Safari" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*iPad).*") THEN "Safari" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*iPhone).*") THEN "Safari" \r\n    ELSE "Other"\r\n    END AS Clean_Browser,\r\n    Platform_Type,\r\n    Report_Day,\r\n    View_Through_Conversions,\r\n    Click_Through_Conversions,\r\n    Total_Conversions\r\n  FROM [PARAMETER].CM_Browser_Floodlight\r\n)\r\n\r\n  SELECT\r\n    *,\r\n    CASE WHEN Platform_Type="Mobile highend: smartphone" OR Platform_Type="Mobile midrange: feature phone" OR Platform_Type="Tablet" THEN Total_Conversions ELSE 0 END AS Mobile_Convs,\r\n   CASE WHEN Platform_Type="Desktop" THEN Total_Conversions ELSE 0 END AS Desktop_Convs,\r\n   CASE WHEN Clean_Browser="Chrome" THEN Total_Conversions ELSE 0 END AS Chrome_Convs,\r\n   CASE WHEN Clean_Browser="Safari" THEN Total_Conversions ELSE 0 END AS Safari_Convs,\r\n   CASE WHEN Clean_Browser="Firefox" THEN Total_Conversions ELSE 0 END AS Firefox_Convs\r\n  FROM browser_clean',
        'legacy': False,
        'parameters': [
          {'field': {'name': 'dataset','kind': 'string','description': 'Bigquery container for data.'}}
        ]
      }
    }
  },
  {
    'bigquery': {
      'auth': 'user',
      'to': {
        'table': 'CM_Browser_Delivery',
        'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'BigQuery dataset to contain data.'}}
      },
      'from': {
        'query': 'WITH\r\nbrowser_clean AS (\r\n  SELECT\r\n    Advertiser,\r\n    Advertiser_Id,\r\n    Campaign,\r\n    Campaign_Id,\r\n    Site_Dcm,\r\n    Browser_Platform,\r\n  CASE\r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*Chrome).*") THEN "Chrome" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*Firefox).*") THEN "Firefox" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*Safari).*") THEN "Safari"\r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*iPad).*") THEN "Safari" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*iPad).*") THEN "Safari" \r\n    WHEN REGEXP_CONTAINS(Browser_Platform, "((?i).*iPhone).*") THEN "Safari" \r\n    ELSE "Other"\r\n    END AS Clean_Browser,\r\n    Platform_Type,\r\n    Report_Day,\r\n    Impressions,\r\n    Clicks,\r\n    View_Through_Conversions,\r\n    Click_Through_Conversions\r\n  FROM [PARAMETER].CM_Browser_Delivery\r\n)\r\n\r\n SELECT\r\n    *,\r\n   CASE WHEN Platform_Type="Mobile highend: smartphone" OR Platform_Type="Mobile midrange: feature phone" OR Platform_Type="Tablet" THEN Impressions ELSE 0 END AS Mobile_Imps,\r\n   CASE WHEN Platform_Type="Desktop" THEN Impressions ELSE 0 END AS Desktop_Imps,\r\n   CASE WHEN Platform_Type="Connected TV" THEN Impressions ELSE 0 END AS CTV_Imps,\r\n   CASE WHEN Clean_Browser="Chrome" THEN Impressions ELSE 0 END AS Chrome_Imps,\r\n   CASE WHEN Clean_Browser="Safari" THEN Impressions ELSE 0 END AS Safari_Imps,\r\n   CASE WHEN Clean_Browser="Firefox" THEN Impressions ELSE 0 END AS Firefox_Imps\r\n  FROM browser_clean',
        'legacy': False,
        'parameters': [
          {'field': {'name': 'dataset','kind': 'string','description': 'Bigquery container for data.'}}
        ]
      }
    }
  },
  {
    'bigquery': {
      'auth': 'user',
      'to': {
        'table': 'DV360_Browser_Delivery',
        'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'BigQuery dataset to contain data.'}}
      },
      'from': {
        'query': 'WITH\r\nbrowser_cleaned AS (\r\n  SELECT \r\n    Advertiser,\r\n    Advertiser_Id,\r\n    Advertiser_Currency,\r\n    Browser,\r\n    Campaign,\r\n    Campaign_Id,\r\n    Insertion_Order, \r\n    Insertion_Order_Id,\r\n    Report_Day,\r\n    Device_Type,\r\n    Environment,\r\n    Impressions,\r\n    Clicks,\r\n    Post_Click_Conversions,\r\n    Post_View_Conversions,\r\n    Revenue_Adv_Currency as Revenue,\r\n    Media_Cost_Advertiser_Currency,\r\n    CASE\r\n      WHEN REGEXP_CONTAINS(Browser, "((?i).*Chrome).*") THEN "Chrome" \r\n      WHEN REGEXP_CONTAINS(Browser, "((?i).*Firefox).*") THEN "Firefox" \r\n      WHEN REGEXP_CONTAINS(Browser, "((?i).*Safari).*") THEN "Safari"\r\n      ELSE "Other"\r\n      END AS Clean_Browser,\r\n    CASE \r\n      WHEN Browser="Safari 12" THEN "Safari 12"\r\n      WHEN Browser="Safari 11" THEN "Safari 11"\r\n      WHEN REGEXP_CONTAINS(Browser, "((?i).*Safari).*") AND Browser!="Safari 12" AND Browser!="Safari 11" THEN "Safari 10 & Below"\r\n      ELSE "Non Safari"\r\n    END AS ITP_Affected_Browsers\r\n   FROM [PARAMETER].DV360_Browser_Delivery \r\n)\r\n\r\n  SELECT\r\n    *,\r\n    CASE WHEN Device_Type="Smart Phone" OR Device_Type="Tablet" THEN Impressions ELSE 0 END AS Mobile_Imps,\r\n   CASE WHEN Device_Type="Desktop" THEN Impressions ELSE 0 END AS Desktop_Imps,\r\n   CASE WHEN Device_Type="Connected TV" THEN Impressions ELSE 0 END AS CTV_Imps,\r\n   CASE WHEN Clean_Browser="Chrome" THEN Impressions ELSE 0 END AS Chrome_Imps,\r\n   CASE WHEN Clean_Browser="Safari" THEN Impressions ELSE 0 END AS Safari_Imps,\r\n   CASE WHEN Clean_Browser="Firefox" THEN Impressions ELSE 0 END AS Firefox_Imps,\r\n    CASE WHEN Clean_Browser="Chrome" THEN Revenue ELSE 0 END AS Chrome_Rev,\r\n   CASE WHEN Clean_Browser="Safari" THEN Revenue ELSE 0 END AS Safari_Rev,\r\n   CASE WHEN Clean_Browser="Firefox" THEN Revenue ELSE 0 END AS Firefox_Rev,\r\n   CASE WHEN Clean_Browser="Chrome" THEN Post_Click_Conversions ELSE 0 END AS Chrome_Click_Convs,\r\n   CASE WHEN Clean_Browser="Safari" THEN Post_Click_Conversions ELSE 0 END AS Safari_Click_Convs,\r\n   CASE WHEN Clean_Browser="Firefox" THEN Post_Click_Conversions ELSE 0 END AS Firefox_Click_Convs,\r\n   CASE WHEN Clean_Browser="Chrome" THEN Post_View_Conversions ELSE 0 END AS Chrome_View_Convs,\r\n   CASE WHEN Clean_Browser="Safari" THEN Post_View_Conversions ELSE 0 END AS Safari_View_Convs,\r\n   CASE WHEN Clean_Browser="Firefox" THEN Post_View_Conversions ELSE 0 END AS Firefox_View_Convs,\r\n   CASE WHEN Clean_Browser="Chrome" THEN Post_Click_Conversions+Post_View_Conversions ELSE 0 END AS Chrome_Convs,\r\n   CASE WHEN Clean_Browser="Safari" THEN Post_Click_Conversions+Post_View_Conversions ELSE 0 END AS Safari_Convs,\r\n   CASE WHEN Clean_Browser="Firefox" THEN Post_Click_Conversions+Post_View_Conversions ELSE 0 END AS Firefox_Convs,\r\n   \r\n   CASE WHEN ITP_Affected_Browsers="Safari 12" THEN Impressions ELSE 0 END AS S12_Imps,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 11" THEN Impressions ELSE 0 END AS S11_Imps,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 10 & Below" THEN Impressions ELSE 0 END AS S_Imps,\r\n   CASE WHEN ITP_Affected_Browsers="Non Safari" THEN Impressions ELSE 0 END AS NS_Imps,\r\n   \r\n   CASE WHEN ITP_Affected_Browsers="Safari 12" THEN Post_Click_Conversions ELSE 0 END AS S12_Click_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 11" THEN Post_Click_Conversions ELSE 0 END AS S11_Click_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 10 & Below" THEN Post_Click_Conversions ELSE 0 END AS S_Click_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Non Safari" THEN Post_Click_Conversions ELSE 0 END AS NS_Click_Convs,\r\n   \r\n   CASE WHEN ITP_Affected_Browsers="Safari 12" THEN Post_View_Conversions ELSE 0 END AS S12_View_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 11" THEN Post_View_Conversions ELSE 0 END AS S11_View_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 10 & Below" THEN Post_View_Conversions ELSE 0 END AS S_View_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Non Safari" THEN Post_View_Conversions ELSE 0 END AS NS_View_Convs,\r\n   \r\n   CASE WHEN ITP_Affected_Browsers="Safari 12" THEN Post_Click_Conversions+Post_View_Conversions ELSE 0 END AS S12_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 11" THEN Post_Click_Conversions+Post_View_Conversions ELSE 0 END AS S11_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Safari 10 & Below" THEN Post_Click_Conversions+Post_View_Conversions ELSE 0 END AS S_Convs,\r\n   CASE WHEN ITP_Affected_Browsers="Non Safari" THEN Post_Click_Conversions+Post_View_Conversions ELSE 0 END AS NS_Convs\r\n   \r\n   \r\n  FROM browser_cleaned',
        'legacy': False,
        'parameters': [
          {'field': {'name': 'dataset','kind': 'string','description': 'Place where tables will be written in BigQuery.'}}
        ]
      }
    }
  },
  {
    'bigquery': {
      'auth': 'user',
      'to': {
        'table': 'Combined_Browser_Delivery',
        'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'BigQuery dataset to contain data.'}}
      },
      'from': {
        'query': 'WITH cm AS ( SELECT Report_Day, CASE  WHEN Platform_Type="Desktop" THEN "Desktop" WHEN Platform_Type="Tablet" THEN "Mobile_Tablet" WHEN Platform_Type="Mobile highend: smartphone" THEN "Mobile_Tablet" WHEN Platform_Type="Mobile midrange: feature phone" THEN "Mobile_Tablet" WHEN Platform_Type="Connected TV" THEN "CTV" END AS Device_Clean, SUM(Impressions) as CM_Impressions FROM `[PARAMETER].CM_Browser_Delivery`  GROUP BY 1,2 ),  dv3 AS ( SELECT Report_Day as RD, CASE  WHEN Device_Type="Desktop" THEN "Desktop" WHEN Device_Type="Tablet" THEN "Mobile_Tablet" WHEN Device_Type="Smart Phone" THEN "Mobile_Tablet" WHEN Device_Type="Connected TV" THEN "CTV" END AS Device_Clean_DV360, SUM(Impressions) as DV360_Impressions FROM `[PARAMETER].DV360_Browser_Delivery`  GROUP BY 1,2 )  SELECT Report_Day, Device_Clean, CM_Impressions, DV360_Impressions FROM cm a JOIN dv3 b ON a.Report_Day=b.RD AND a.Device_Clean=b.Device_Clean_DV360',
        'legacy': False,
        'parameters': [
          {'field': {'name': 'dataset','kind': 'string','description': 'Place where tables will be written in BigQuery.'}},
          {'field': {'name': 'dataset','kind': 'string','description': 'Place where tables will be written in BigQuery.'}}
        ]
      }
    }
  }
]

json_set_fields(TASKS, FIELDS)
project.initialize(_recipe={ 'tasks':TASKS }, _project=CLOUD_PROJECT, _user=USER_CREDENTIALS, _client=CLIENT_CREDENTIALS, _verbose=True)
project.execute()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14255565670777126, 'fraction_numerical': 0.007986427211785153, 'mean_word_length': 2.5157113762001746, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 24, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '267920', 'license': 'Apache-2.0', 'n_tokens_mistral': 8097, 'n_tokens_neox': 7521, 'n_words': 1752, 'path': 'colabs/itp.ipynb', 'repo_name': 'RMStanford/starthinker', 'size': '24166'}