Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMPORT FOREIGN SCHEMA #1

Closed
vpicavet opened this issue Feb 26, 2016 · 4 comments
Closed

IMPORT FOREIGN SCHEMA #1

vpicavet opened this issue Feb 26, 2016 · 4 comments

Comments

@vpicavet
Copy link
Contributor

It would be nice to implement an import foreign schema for various datasources.
For each dataset it would create the metadata and the data tables.

On problem for this is that we need to have pointcloud_formats populated before creating the data table. And we want to generate the pcid schema thanks to the metadata FDW.
Ways to workaround :

  • before giving the table schema back, we execute an insert on pointcloud_formats
  • hide this behind a SQL or PL/PgSQL function which does the insert and then import the foreign schema

This could lead to some unnecessary elements in pointcloud_formats whenever the import foreign schema is rollbacked, but there does not seem to be a better way, and this is not that annoying.

@mbredif
Copy link

mbredif commented May 24, 2017

I propose the following loosely coupled solution :

  1. having the fdw expose a metadata foreign table named "pointcloud_formats", with columns ("pcid", "srid" and "schema") that contains all the rows that have to be inserted in pgpointcloud's "pointcloud_formats" table. The pcid would there be the foreign pcid, to be referenced by the columns of the foreign tables. This table only could be imported with an import foreign schema with a limit clause.
  2. have a function that compares the local and foreign "pointcloud_formats" schemas and srids, that would retrieve the mapping from the foreign pcids to the local pcid, possibly after insertion if no local match is found.
  3. have the import foreign schema and the create foreign table commands accept as an option a mapping from the foreign pcid to the local pcid.

The whole process could finally be wrapped into a function if required, but that is just for convenience.
As a side note, addressing pgpointcloud/pointcloud#95 might help us here in 2.

@elemoine
Copy link
Contributor

Questions regarding your proposal:

In 2. you mention having a function that would handle the mappings between the local and foreign "pointcloud_formats" tables. How/where would you define that function? fdw-li3ds is not a Postgres extension, so it doesn't have an SQL file. We could still define that function in an SQL file, and refer to it in the documentation. Have you envisioned something fancier than that?

In 3. you mention passing pcid mappings to import foreign schema and create foreign table. Do you know if complex option values are possible?

Thanks.

@mbredif
Copy link

mbredif commented Jun 8, 2017

  1. nothing more, I was counting on you :)
  2. good point. Anyhow, if only a string is tolerated, on could specify this mapping using a comma-separated list of integers, if we restrict foreign pcids to be contiguous.

@elemoine
Copy link
Contributor

Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants