timely icon indicating copy to clipboard operation
timely copied to clipboard

SQL Interface

Open klucar opened this issue 8 years ago • 1 comments

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 avatar Oct 14 '16 15:10 klucar

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

klucar avatar Oct 14 '16 16:10 klucar