bqshift

command module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

README

bqshift

Automate copy of Redshift data to BigQuery.

Building

$ go get github.com/uswitch/bqshift
$ go install github.com/uswitch/bqshift

Running

$ export GCLOUD_PROJECT=project-id
$ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/creds.json
$ bqshift --config=config.example.yml <DEST DATASET> <REDSHIFT TABLE>
Time Partitioned Tables

BigQuery supports Partitioned Tables.

By dividing a large table into smaller partitions, you can improve query performance and reduce the number of bytes billed by restricting the amount of data scanned. BigQuery enables you to partition tables by date.

bqshift can load partitioned data as long as the source data has date information stored, the destination table in BigQuery must also have been declared as time partitioned when it was created. bqshift can automatically create the correct table if it hasn't already been created.

For example, to create a partitioned table from a table that has a TIMESTAMP column called ts, and to load data into the 2016-09-27 partition you can use the following command:

$ bqshift --partition --date-expression="CAST(ts as DATE)" --date=2016-09-27 --config=config.example.yml <DEST DATASET> <REDSHIFT TABLE>
Overwriting Partitioned Data

It's possible to replace/update an existing partition by adding the --overwrite flag.

$ bqshift --overwrite --partition --date-expression="CAST(ts as DATE)" --date=2016-09-27 --config=config.example.yml <DEST DATASET> <REDSHIFT TABLE>

Note that you can only update data that was already part of a partition. For example, if you were to create a partitioned table and load a bulk set of historical/archived data when you use --overwrite and --date you'll overwrite all data in the table. Instead I would suggest having a separate _archive table from the partitioned tables.

Notes

As part of the unloading process bqshift generates SQL for Redshift; this is not protected against SQL injection attacks so beware of using this tool with user-generated input.

Releasing

We use https://github.com/progrium/gh-release to tag and release artifacts. Install with:

$ go get github.com/progrium/gh-release

Then to release use:

$ VERSION=<...> make gh-release

License

Copyright (c) 2016, uSwitch All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of uSwitch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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