NationalSecurityAgency / timely

Accumulo backed time series database
https://code.nsa.gov/timely/
Apache License 2.0
379 stars 110 forks source link

SQL Interface #98

Open klucar opened 7 years ago

klucar commented 7 years ago

Postgres has a foreign data wrapper capability that allows you to expose data to postgres. The postgres engine will process sql queries over your data set. I did some experimentation with this in my fdw branch of my fork of timely.

The python I wrote is in these gists: https://gist.github.com/klucar/2ca41402608a92c5bc2353add3491f9a https://gist.github.com/klucar/001c6d8df2beb307abcbc3f038292fe1

The python interface enabling this is called Multicorn http://multicorn.org

klucar commented 7 years ago

here's a SQL blob that worked when I had all this hooked up:

CREATE EXTENSION IF NOT EXISTS multicorn;
DROP SERVER IF EXISTS multicorn_timely CASCADE;
CREATE SERVER multicorn_timely FOREIGN DATA WRAPPER multicorn
OPTIONS ( wrapper 'timelyfdw.TimelyForeignDataWrapper' );

CREATE FOREIGN TABLE test (
    a varchar,
    b varchar,
    c varchar,
    d varchar
) SERVER multicorn_timely OPTIONS (
    host 'tb081',
    port '10000',
    table 'test'
);

SELECT * FROM test WHERE a != '0';