Skip to main content

BigQuery Foreign Data Wrapper for PostgreSQL

Project description

bigquery\_fdw: BigQuery Foreign Data Wrapper for PostgreSQL
===========================================================

bigquery\_fdw is a BigQuery foreign data wrapper for PostgreSQL using
`Multicorn <https://github.com/Kozea/Multicorn>`__.

It allows to write queries in PostgreSQL SQL syntax using a foreign
table. It supports most of BigQuery's `data
types <docs/data_types.md>`__ and `operators <docs/operators.md>`__.

Features and limitations
------------------------

- Table partitioning is supported. `You can use partitions in your SQL
queries <docs/table_partitioning.md>`__.
- Queries are parameterized when sent to BigQuery
- BigQuery's standard SQL support (legacy SQL is not supported)
- Authentication works with a "`Service
Account <docs/service_account.md>`__" Json private key

`Read more <docs/README.md>`__.

Requirements
------------

- PostgreSQL >= 9.5
- Python 3

Dependencies
------------

Dependencies required to install bigquery\_fdw:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``postgresql-server-dev-X.Y``
- ``python3-pip``
- ``python3-dev``
- ``make``
- ``gcc``

Major dependencies installed automatically during the installation process:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- `Google Cloud
BigQuery <https://pypi.org/project/google-cloud-bigquery/>`__
- `Multicorn <https://github.com/Kozea/Multicorn>`__

Installation
------------

.. code:: bash

# Install `setuptools` if necessary
pip3 install --upgrade setuptools

# Install Multicorn
git clone git://github.com/Kozea/Multicorn.git && cd Multicorn
export PYTHON_OVERRIDE=python3
make && make install

# Install bigquery_fdw
pip3 install bigquery-fdw

Usage
-----

We recommend testing the `BigQuery client
connectivity <docs/test_client.md>`__ before trying to use the FDW.

With ``psql``:

.. code:: sql

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',
fdw_key '/opt/bigquery_fdw/user.json'
);

Options
-------

List of options implemented in ``CREATE FOREIGN TABLE`` syntax:

+--------+-------+-------+
| Option | Defau | Descr |
| | lt | iptio |
| | | n |
+========+=======+=======+
| ``fdw_ | - | BigQu |
| datase | | ery |
| t`` | | datas |
| | | et |
| | | name |
+--------+-------+-------+
| ``fdw_ | - | BigQu |
| table` | | ery |
| ` | | table |
| | | name |
+--------+-------+-------+
| ``fdw_ | - | Path |
| key`` | | to |
| | | priva |
| | | te |
| | | Json |
| | | key |
| | | (See |
| | | `Key |
| | | stora |
| | | ge |
| | | recom |
| | | menda |
| | | tions |
| | | <doc |
| | | s/key |
| | | _stor |
| | | age.m |
| | | d>`__ |
| | | ) |
+--------+-------+-------+
| ``fdw_ | - | Conve |
| conver | | rt |
| t_tz`` | | BigQu |
| | | ery |
| | | time |
| | | zone |
| | | for |
| | | dates |
| | | and |
| | | times |
| | | tamps |
| | | to |
| | | selec |
| | | ted |
| | | time |
| | | zone. |
| | | Examp |
| | | le: |
| | | ``'US |
| | | /East |
| | | ern'` |
| | | `. |
+--------+-------+-------+
| ``fdw_ | ``'fa | See |
| group` | lse'` | `Remo |
| ` | ` | te |
| | | group |
| | | ing |
| | | and |
| | | count |
| | | ing < |
| | | docs/ |
| | | remot |
| | | e_gro |
| | | uping |
| | | .md>` |
| | | __. |
+--------+-------+-------+
| ``fdw_ | - | See |
| castin | | `Cast |
| g`` | | ing < |
| | | docs/ |
| | | casti |
| | | ng.md |
| | | >`__. |
+--------+-------+-------+
| ``fdw_ | ``'fa | Set |
| verbos | lse'` | to |
| e`` | ` | ``'tr |
| | | ue'`` |
| | | to |
| | | outpu |
| | | t |
| | | debug |
| | | infor |
| | | matio |
| | | n |
| | | in |
| | | Postr |
| | | geSQL |
| | | 's |
| | | logs |
+--------+-------+-------+
| ``fdw_ | ``'st | BigQu |
| sql_di | andar | ery |
| alect` | d'`` | SQL |
| ` | | diale |
| | | ct. |
| | | Curre |
| | | ntly |
| | | only |
| | | ``sta |
| | | ndard |
| | | `` |
| | | is |
| | | suppo |
| | | rted. |
+--------+-------+-------+

More documentation
------------------

See `bigquery\_fdw documentation <docs/README.md>`__.


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-1.2.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

bigquery_fdw-1.2-py2.py3-none-any.whl (12.1 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: bigquery-fdw-1.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bigquery-fdw-1.2.tar.gz
Algorithm Hash digest
SHA256 061e33a6f58a3a174877f1d6bc91338b047c43aae5f9884fb5285bb4d78b9a88
MD5 4c8c70c2240709c3ecda38c2a6b9ba57
BLAKE2b-256 ebb0d84e29c5d4af952953abaf1308f28da5ccff1de24e9e1966ff23af3e41da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bigquery_fdw-1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ba7d5511c0052b858c6a2ef1937f8dc5db2928acf40154433ae5e5e1f2a6ff34
MD5 35567df62a6662a80b84ef0363573c72
BLAKE2b-256 f3fb8b734198779765845fbf3bdd26d767fc9beecae31f849f3a586fd6b85bb3

See more details on using hashes here.

Supported by

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