CDB_Federated_Table_Register: Reuse webmercator_column if geom_column is NULL

This commit is contained in:
Raúl Marín 2019-12-10 18:08:25 +01:00
parent 9372c9f4e0
commit dac135890d
3 changed files with 14 additions and 6 deletions

View File

@ -214,9 +214,11 @@ BEGIN
RAISE EXCEPTION 'Remote table name cannot be NULL';
END IF;
-- Use geom_column as default for webmercator_column
-- Make do with whatever columns are provided
IF webmercator_column IS NULL THEN
webmercator_column := geom_column;
ELSIF geom_column IS NULL THEN
geom_column := webmercator_column;
END IF;
IF local_name IS NULL THEN

View File

@ -213,14 +213,17 @@ SELECT cartodb.CDB_Federated_Table_Register(
geom_column => 'Does not exists'
);
\echo '## Registering a table: NULL geom_column is OK'
\echo '## Registering a table: NULL geom_column is OK: Reuses geom_mercator'
SELECT cartodb.CDB_Federated_Table_Register(
server => 'loopback',
remote_schema => 'remote_schema',
remote_table => 'remote_geom',
id_column => 'id',
geom_column => NULL::text
geom_column => NULL::text,
webmercator_column => 'geom'
);
SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Tables(server => 'loopback', remote_schema => 'remote_schema') where remote_table = 'remote_geom';
SELECT cartodb.CDB_Federated_Table_Unregister(
server => 'loopback',
remote_schema => 'remote_schema',
@ -237,7 +240,7 @@ SELECT cartodb.CDB_Federated_Table_Register(
webmercator_column => 'Does not exists'
);
\echo '## Registering a table: NULL webmercator_column is OK'
\echo '## Registering a table: NULL webmercator_column is OK: Reuses geom'
SELECT cartodb.CDB_Federated_Table_Register(
server => 'loopback',
remote_schema => 'remote_schema',
@ -246,6 +249,7 @@ SELECT cartodb.CDB_Federated_Table_Register(
geom_column => 'geom',
webmercator_column => NULL::text
);
SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Tables(server => 'loopback', remote_schema => 'remote_schema') where remote_table = 'remote_geom';
SELECT cartodb.CDB_Federated_Table_Unregister(
server => 'loopback',
remote_schema => 'remote_schema',

View File

@ -43,13 +43,15 @@ ERROR: non integer id_column "Does not exist"
ERROR: non integer id_column "<NULL>"
## Registering a table: Invalid geom_column fails
ERROR: non geometry column "Does not exists"
## Registering a table: NULL geom_column is OK
## Registering a table: NULL geom_column is OK: Reuses geom_mercator
t|remote_geom|cdb_fs_loopback.remote_geom|id|geom|geom|[{"Name" : "another_field", "Type" : "text"}, {"Name" : "geom", "Type" : "GEOMETRY,4326"}, {"Name" : "id", "Type" : "integer"}]
## Registering a table: Invalid webmercator_column fails
ERROR: non geometry column "Does not exists"
## Registering a table: NULL webmercator_column is OK
## Registering a table: NULL webmercator_column is OK: Reuses geom
t|remote_geom|cdb_fs_loopback.remote_geom|id|geom|geom|[{"Name" : "another_field", "Type" : "text"}, {"Name" : "geom", "Type" : "GEOMETRY,4326"}, {"Name" : "id", "Type" : "integer"}]
##Registering a table with extra columns show the correct information