Skip to main content

bigquery_fdw: BigQuery Foreign Data Wrapper for PostgreSQL

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.

Metadata

Release files for bigquery-fdw 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bigquery-fdw 2.1.2
File Size Uploaded
bigquery-fdw-2.1.2.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bigquery-fdw 2.1.2
File Interpreter ABI Platform
bigquery_fdw-2.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 21.5 kB

Release files / bigquery-fdw-2.1.2.tar.gz

Download URL bigquery-fdw-2.1.2.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fc281dc9bc7bd48b161b55cfeb8dc6a922df46cd1c783ea9d4b19a2d0e19e092
BLAKE2b-256 checksum
How to use checksums
87d8a4b0cd453951ef0864a6c99ea4847d27f63c7b83fdf08c7627931656f147
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / bigquery_fdw-2.1.2-py2.py3-none-any.whl

Download URL bigquery_fdw-2.1.2-py2.py3-none-any.whl
Size 10.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ce78b29464be0636707835720fe7517106903602678d13c895ddfde49d644377
BLAKE2b-256 checksum
How to use checksums
e36a7e4a8e3f52ed228699dd04b5496511b9efada9d80f34e849072d65eb1794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

2.1.2 This release

2 release files

2.1.1

2 release files

2.1

2 release files

2.0

2 release files

1.9

2 release files

1.8

2 release files

1.7

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page