Giter Site home page Giter Site logo

petergebruers / influxdb_fdw Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pgspider/influxdb_fdw

0.0 0.0 0.0 869 KB

InfluxDB Foreign Data Wrapper for PostgreSQL.

License: Other

Makefile 0.31% C 31.91% C++ 1.56% Shell 0.26% Go 2.62% PLpgSQL 58.10% TSQL 2.83% SQLPL 2.40%

influxdb_fdw's Introduction

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, 11 and 12.

Go version should be 1.10.4 or later.

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 with_llvm=no
make install USE_PGXS=1 with_llvm=no

with_llvm=no is necessary to disable llvm bit code generation when PostgreSQL is configured with --with-llvm because influxdb_fdw use go code and cannot be compiled to llvm bit code.

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

make with_llvm=no
make install  with_llvm=no

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');

Import foreign schema

IMPORT FOREIGN SCHEMA public FROM SERVER influxdb_server INTO public;

Access foreign table

SELECT * FROM t1;

Features

InfluxDB FDW supports pushed-down functions

  • WHERE clauses including timestamp, interval and now() functions are pushed down
  • Some of aggregation are pushed down such as influx_time and last functions. These functions does not work on PostgreSQL 9.

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.
  • Timestamp precision may be lost because timestamp resolution of PostgreSQL is microseconds while that of InfluxDB is nanoseconds.
  • Conditions like WHERE time + interval '1 day' < now() do not work. Please use WHERE time < now() - interval '1 day'.
  • GROUP BY time does not work ((#19).
  • Conditions have mix usage of aggregate function and arithmetic do not work (#18).
  • GROUP BY does not support FIELD KEY having arithmetic (#17).
  • GROUP BY only works with time and tag dimensions (#16).
  • GROUP BY does not work with duplicated targets (#15).
  • Aggregate functions with arithmetic in parentheses are not supported (#14).
  • String comparisons do not work except = and != (#13).
  • GROUP BY works for only tag keys, not for field keys(#3)

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

Contributing

Opening issues and pull requests on GitHub are welcome.

License

Copyright (c) 2018 - 2020, 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.