Segfault-Inc / Multicorn

Data Access Library
https://multicorn.org/
PostgreSQL License
701 stars 145 forks source link

Creating FDW Server with multiple Tables #129

Closed justinjoseph89 closed 8 years ago

justinjoseph89 commented 8 years ago

I have two tables in Cassandra - activity1 and activity2,

I already created two servers using the following queries

CREATE SERVER server_activity1 FOREIGN DATA WRAPPER multicorn options ( wrapper 'pgCassandra.CassandraFDW', port '9042', columnfamily 'activity1', keyspace 'keyspace', hosts '192.168.1.1' );

which is working fine for us, but when I want to connect with the second table here I need to create another server?

CREATE SERVER server_activity2 FOREIGN DATA WRAPPER multicorn options ( wrapper 'pgCassandra.CassandraFDW', port '9042', columnfamily 'activity2, keyspace 'keyspace', hosts '192.168.1.1' );

OR Can we use the same server for both the tables (columnfamily)?

Some one pls advice.

rdunklau commented 8 years ago

You can either create anoher server if you want, but its better to set the options at the table level. I don"t know the cassandra fdw, but you should be able to do something like this:

CREATE FOREIGN TABLE .... OPTIONS (columnfamily 'activity2');

ratheesh-kr commented 8 years ago

thanks for your help,

But while querying the data, can we use activity1., activity2. .

How we can fetch the data from the tables if we add the columnfamily as OPTIONS?

rdunklau commented 8 years ago

I don't know how this particular FDW work, since I've never used it. If they are in the same table, then you can query them llike you would any "normal" table's columns, and if they aren't, you can JOIN them together (which will be very expensive, since data from both tables would have to be retrieved).

You should ask the cassandra FDW author for advice as how it works, and if its possible to map two "columnfamilies" in the same table (I have no idea what that is, having never used cassandra either).

ratheesh-kr commented 8 years ago

Thanks for your help Ronan..!!