InfluxDB Foreign Data Wrapper for PostgreSQL.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
expected
sql
License
Makefile PostgreSQL 11 support Dec 5, 2018
README.md
deparse.c
influxdb_fdw--1.0.sql
influxdb_fdw.c
influxdb_fdw.control
influxdb_fdw.h
influxdb_query.c
init.sh
init.txt
option.c
query.go
test.sh

README.md

InfluxDB Foreign Data Wrapper for PostgreSQL

This PostgreSQL extension is a Foreign Data Wrapper (FDW) for InfluxDB.

The current version can work with PostgreSQL 9.6, 10 and 11.

Installation

Install InfluxDB Go client library

go get github.com/influxdata/influxdb1-client/v2

Add a directory of pg_config to PATH and build and install influxdb_fdw.

make USE_PGXS=1
make install USE_PGXS=1

If you want to build influxdb_fdw in a source tree of PostgreSQL instead, use

make
make install

Usage

Load extension

CREATE EXTENSION influxdb_fdw;

Create server

CREATE SERVER influxdb_server FOREIGN DATA WRAPPER influxdb_fdw OPTIONS
(dbname 'mydb', host 'http://localhost', port '8086') ;

Create user mapping

CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_server OPTIONS(user 'user', password 'pass');

Create foreign table

You need to declare a column named "time" to access InfluxDB time column.

CREATE FOREIGN TABLE t1(time timestamp with time zone , tag1 text, field1 integer) SERVER influxdb_server OPTIONS (table 'measurement1');

Or you can use import foreign schema

IMPORT FOREIGN SCHEMA public FROM SERVER influxdb_server INTO public;

Access foregin table

SELECT * FROM t1;

Features

  • WHERE clauses including timestamp, interval and now functions are pushed down
  • Simple aggregation without GROUP BY are pushed down

Limitations

  • INSERT, UPDATE and DELETE are not supported.

Following limitations originate from data model and query language of InfluxDB.

  • Result sets have different number of rows depending on specified target list. For example, SELECT field1 FROM t1 and SELECT field2 FROM t1 returns different number of rows if the number of points with field1 and field2 are different in InfluxDB database.
  • Complex boolean conditions not allowed in InfluxDB like WHERE b = (a = true) may cause error.
  • Conditions including NULL may cause error.

When a query to foreing tables fails, you can find why it fails by seeing a query executed in InfluxDB with EXPLAIN (VERBOSE).

License

Copyright (c) 2018, TOSHIBA Corporation Copyright (c) 2011 - 2016, EnterpriseDB Corporation

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

See the LICENSE file for full details.