Skip to main content

BigQuery Foreign Data Wrapper for PostgreSQL

Project description

Pypi Build Status codecov MIT licensed

bigquery_fdw is a BigQuery foreign data wrapper for PostgreSQL using Multicorn.

It allows to write queries in PostgreSQL SQL syntax using a foreign table. It supports most of BigQuery’s data types and operators.

Features and limitations

Read more.

Requirements

  • PostgreSQL >= 9.5 up to 14

  • Python >= 3.4

Get started

Using docker

See getting started with Docker

Installation on Debian/Ubuntu

Dependencies required to install bigquery_fdw:

You need to install the following dependencies:

# Install required packages
apt update
apt install -y postgresql-server-dev-14 python3-setuptools python3-dev make gcc git

All PostgreSQL versions from 9.2 to 14 should be supported.

Installation

# Install Multicorn
# pgsql-io/multicorn2 is a fork of Segfault-Inc/Multicorn that adds support for PostgreSQL 13/14.
# Alternatively, up to PostgreSQL 12, you can use gabfl/Multicorn that adds better support for Python3.
# You may also choose to build against the original project instead.
git clone https://github.com/pgsql-io/multicorn2.git Multicorn && cd Multicorn
make && make install

# Install bigquery_fdw
pip3 install bigquery-fdw

Major dependencies installed automatically during the installation process:

Authentication

bigquery_fdw relies on Google Cloud API’s default authentication.

Your need to have an environment variable GOOGLE_APPLICATION_CREDENTIALS that has to be accessible by bigquery_fdw. Setting environment variables varies depending on OS but for Ubuntu or Debian, the preferred way is to edit /etc/postgresql/[version]/main/environment and add:

GOOGLE_APPLICATION_CREDENTIALS = '/path/to/key.json'

Restarting PostgreSQL is required for the environment variable to be loaded.

Usage

We recommend testing the BigQuery client connectivity before trying to use the FDW.

With psql:

CREATE EXTENSION multicorn;

CREATE SERVER bigquery_srv FOREIGN DATA WRAPPER multicorn
OPTIONS (
    wrapper 'bigquery_fdw.fdw.ConstantForeignDataWrapper'
);

CREATE FOREIGN TABLE my_bigquery_table (
    column1 text,
    column2 bigint
) SERVER bigquery_srv
OPTIONS (
    fdw_dataset  'my_dataset',
    fdw_table 'my_table'
);

Options

List of options implemented in CREATE FOREIGN TABLE syntax:

Option

Default

Description

fdw_dataset

BigQuery dataset name

fdw_table

BigQuery table name

fdw_convert_tz

Convert BigQuery time zone for dates and timestamps to selected time zone. Example: 'US/Eastern'.

fdw_group

'false'

See Remote grouping and counting.

fdw_casting

See Casting.

fdw_verbose

'false'

Set to 'true' to output debug information in PostrgeSQL’s logs

fdw_sql_dialect

'standard'

BigQuery SQL dialect. Currently only standard is supported.

More documentation

See bigquery_fdw documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bigquery-fdw-2.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

bigquery_fdw-2.0-py2.py3-none-any.whl (10.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file bigquery-fdw-2.0.tar.gz.

File metadata

  • Download URL: bigquery-fdw-2.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for bigquery-fdw-2.0.tar.gz
Algorithm Hash digest
SHA256 9b3f31e0f9ec05bf43c4f82bbcad39ad3f13b0fa8802c8ececaf1594ebecb3dd
MD5 6b68563b52919bde284aed2e780283ae
BLAKE2b-256 6cbedfba6dffcc9d978e6071170632c2843bd169bb76169fb5e737f2752590f4

See more details on using hashes here.

File details

Details for the file bigquery_fdw-2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: bigquery_fdw-2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for bigquery_fdw-2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7774ab8b2659a26bb6d0199cdf6b8b0a06ec5fb60ffb65c85e6f13d1b0fafcfe
MD5 435b28b4a31c8a4b801375040d085854
BLAKE2b-256 9cd3d38c7e5dadcc4a7b13496cdcb767225ddb036f7b7b9a054c729903199153

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page