Giter Club home page Giter Club logo

bigquery-ingest-avro-dataflow-sample's Introduction

This tutorial describes storing Avro SpecificRecord objects in BigQuery using Cloud Dataflow by automatically generating the table schema and transforming the input elements. This tutorial also showcases the usage of Avro-generated classes to materialize or transmit intermediate data between workers in your Cloud Dataflow pipeline.

Please refer to the related article for all the steps to follow in this tutorial.

Contents of this repository:

  • BeamAvro: Java code for the Apache Beam pipeline deployed on Cloud Dataflow.
  • generator: Python code for the randomized event generator.

To run the example:

  1. Update configuration by updating env.sh
  2. Set environment variables
    source env.sh
  3. Generate java beans from the avro file and Run Dataflow pipeline:
    mvn clean generate-sources compile exec:java \
      -Dexec.mainClass=com.google.cloud.solutions.beamavro.AvroToBigQuery \
      -Dexec.cleanupDaemonThreads=false \
      -Dexec.args=" \
    --project=$GOOGLE_CLOUD_PROJECT \
    --runner=DataflowRunner \
    --stagingLocation=gs://$MY_BUCKET/stage/ \
    --tempLocation=gs://$MY_BUCKET/temp/ \
    --inputPath=projects/$GOOGLE_CLOUD_PROJECT/topics/$MY_TOPIC \
    --workerMachineType=n1-standard-1 \
    --maxNumWorkers=$NUM_WORKERS \
    --region=$REGION \
    --dataset=$BQ_DATASET \
    --bqTable=$BQ_TABLE \
    --outputPath=$AVRO_OUT" \
    --file BeamAvro/pom.xml
  4. Run event generation script:
    1. Create Python virtual environment
      python3 -m venv ~/generator-venv
      source ~/generator-venv/bin/activate
    2. Install python dependencies
      pip install -r generator/requirements.txt
    3. Run the Generator
      python generator/gen.py -p $GOOGLE_CLOUD_PROJECT -t $MY_TOPIC -n 100 -f avro

bigquery-ingest-avro-dataflow-sample's People

Contributors

anantdamle avatar varundhussa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.