Giter VIP home page Giter VIP logo

functions-bq-load-job's Introduction

Cloud Functions: Cloud Storage To BigQuery Load Job

This code triggers a BigQuery load job when a file is written to a Google Cloud Storage bucket.

View the source code.

Deploy and Test

  1. Follow the Cloud Functions quickstart guide to setup Cloud Functions for your project.

  2. Clone this repository:

     git clone https://github.com/asaharland/functions-bq-load-job
    
  3. Create a Cloud Storage Bucket:

     gsutil mb gs://BUCKET_NAME
    
    • Replace BUCKET_NAME with the name of your Cloud Storage Bucket.
  4. Deploy the "loadFile" function with an HTTP trigger:

     gcloud functions deploy loadFile --runtime nodejs8 --trigger-resource gs://BUCKET_NAME --trigger-event google.storage.object.finalize
    
  5. Create a BigQuery dataset and a table with the following schema:

     user_id:STRING,amount:FLOAT
    
  6. Update the variables datasetId and tableId in index.js to reflect the dataset and table you created in the previous step.

  7. Upload 'sample.csv', located in the root of this repo, to your bucket:

     gsutil cp sample.csv gs://BUCKET_NAME
    
    • Replace YOUR_BUCKET_NAME with the name of your Cloud Storage Bucket.
  8. Query the BigQuery table to check that you can see that the data has been inserted successfully.

functions-bq-load-job's People

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.