Creates a UDF that extends the Pub/Sub Topic to BigQuery template.

## Code sample

### Node.js


To authenticate to Dataflow, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    /**
     * User-defined function (UDF) to transform events
     * as part of a Dataflow template job.
     *
     * @param {string} inJson input Pub/Sub JSON message (stringified)
     */
     function process(inJson) {
        const obj = JSON.parse(inJson);
        const includePubsubMessage = obj.data && obj.attributes;
        const data = includePubsubMessage ? obj.data : obj;

        if (!data.hasOwnProperty('url')) {
          throw new Error("No url found");
        } else if (data.url !== "https://beam.apache.org/") {
          throw new Error("Unrecognized url");
        }

        return JSON.stringify(obj);
      }

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=dataflow).