title: Using SQL Query to return value from BigQuery User Defined Function
body: <p>Can I use a query in <strong>Google BigQuery User Defined Function</strong> to return some value? I've been searching docs and stackoverflow for hours without any luck and I have a very specific use case where I need to return a single scalar value based on the values of multiple columns.</p>
  
  <p>Following will be the use case for the query:</p>
  
  <pre><code>SELECT campaign,source,medium, get_channel(campaign,source,medium)
  FROM table_name
  </code></pre>
  
  <p>the <em>get_channel()</em> UDF will use these parameters and a complex select statement to return a single scalar value for the row. I've prepared the query, I just need to find a way to use that query in the UDF, for which I, honestly am at loss and without a cause.</p>
  
  <p>Is my use case correct? Is this even possible? Are there any alternatives to do this?</p>