title: How to create reusable UDF in BigQuery
body: <p>I had implemented one <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/user-defined-functions" rel="nofollow noreferrer">User Defined Function</a> which parsed complex JSON and returned hundreds of fields to generate new table.</p>
  
  <pre><code>CREATE TEMP FUNCTION
    PARSE_DATA(input STRING)
    RETURNS STRUCT&lt;field_a STRING,
    field_b STRING,
    field_c ARRAY&lt;STRUCT&lt;...&gt;&gt;,
    ...
    field_xxx STRING&gt;
  LANGUAGE js AS """
  return parseData(input)
  """
    OPTIONS (
    library="gs://foo/bar.js"
  );
  </code></pre>
  
  <p>Since most of JSON are quite similar, I had already implemented one JS UDF to return different schemas. My question is how could I reuse this UDF via changing <strong>RETURNS STRUCT</strong> to generate different tables?</p>