bqschema-gen-go

command module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2022 License: MIT Imports: 15 Imported by: 0

README

bqschema-gen-go

BigQuery table schema Go struct generator

main codecov

generate

How to generate
cd /path/to/your/golang-project-repository

# Create a directory where bqschema-gen-go will generate the code.
mkdir -p bqschema
cd bqschema

# Set the required environment variables.
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/serviceaccount/keyfile.json
# Set GCP Project ID ref. https://console.cloud.google.com/bigquery?p=bigquery-public-data&page=project
export GCLOUD_PROJECT_ID=bigquery-public-data
# Set BigQuery Dataset name ref. https://console.cloud.google.com/bigquery?p=bigquery-public-data&d=hacker_news&page=dataset
export BIGQUERY_DATASET=hacker_news
# Set output file
export OUTPUT_FILE=bqschema.generated.go

# generate
go run github.com/newtstat/bqschema-gen-go

Example generated file content:

// Code generated by go run github.com/newtstat/bqschema-gen-go; DO NOT EDIT.

//go:generate go run github.com/newtstat/bqschema-gen-go

package bqschema

import "time"

// Comments is BigQuery Table `bigquery-public-data:hacker_news.comments` schema struct.
// Description:
type Comments struct {
	Id      int64     `bigquery:"id"`
	By      string    `bigquery:"by"`
	Author  string    `bigquery:"author"`
	Time    int64     `bigquery:"time"`
	Time_ts time.Time `bigquery:"time_ts"`
	Text    string    `bigquery:"text"`
	Parent  int64     `bigquery:"parent"`
	Deleted bool      `bigquery:"deleted"`
	Dead    bool      `bigquery:"dead"`
	Ranking int64     `bigquery:"ranking"`
}

// Full is BigQuery Table `bigquery-public-data:hacker_news.full` schema struct.
// Description: A full daily update of all the stories and comments in Hacker News.
type Full struct {
	Title       string    `bigquery:"title"`
	Url         string    `bigquery:"url"`
	Text        string    `bigquery:"text"`
	Dead        bool      `bigquery:"dead"`
	By          string    `bigquery:"by"`
	Score       int64     `bigquery:"score"`
	Time        int64     `bigquery:"time"`
	Timestamp   time.Time `bigquery:"timestamp"`
	Type        string    `bigquery:"type"`
	Id          int64     `bigquery:"id"`
	Parent      int64     `bigquery:"parent"`
	Descendants int64     `bigquery:"descendants"`
	Ranking     int64     `bigquery:"ranking"`
	Deleted     bool      `bigquery:"deleted"`
}

// Full_201510 is BigQuery Table `bigquery-public-data:hacker_news.full_201510` schema struct.
// Description:
type Full_201510 struct {
	By          string `bigquery:"by"`
	Score       int64  `bigquery:"score"`
	Time        int64  `bigquery:"time"`
	Title       string `bigquery:"title"`
	Type        string `bigquery:"type"`
	Url         string `bigquery:"url"`
	Text        string `bigquery:"text"`
	Parent      int64  `bigquery:"parent"`
	Deleted     bool   `bigquery:"deleted"`
	Dead        bool   `bigquery:"dead"`
	Descendants int64  `bigquery:"descendants"`
	Id          int64  `bigquery:"id"`
	Ranking     int64  `bigquery:"ranking"`
}

// Stories is BigQuery Table `bigquery-public-data:hacker_news.stories` schema struct.
// Description:
type Stories struct {
	Id          int64     `bigquery:"id"`
	By          string    `bigquery:"by"`
	Score       int64     `bigquery:"score"`
	Time        int64     `bigquery:"time"`
	Time_ts     time.Time `bigquery:"time_ts"`
	Title       string    `bigquery:"title"`
	Url         string    `bigquery:"url"`
	Text        string    `bigquery:"text"`
	Deleted     bool      `bigquery:"deleted"`
	Dead        bool      `bigquery:"dead"`
	Descendants int64     `bigquery:"descendants"`
	Author      string    `bigquery:"author"`
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL