1

I'm trying to create data tables by SQL and visualize them by CARTO editor.

But between my local and CARTO environments, the results of CartoDBfy were different : local was failed and CARTO was success.

What is the different between each environments? And what should I do to deal with the table in CARTO editor?

Details are bellow.

1. Local Environment

I built the development CartoDB environment on cloud server, according to 'http://cartodb.readthedocs.io/en/latest/install.html'. The installation was finished successfully and I can use CARTO without problems.

Then I created and CartoDBfy'ed a table like this

CREATE TABLE public.test (
    cartodb_id INTEGER,
    the_geom geometry(Geometry,4326),
    the_geom_webmercator geometry(Geometry,3857),
    code character(4) NOT NULL
);

SELECT cdb_cartodbfytable('test');

These queries were finished successfully. The returned message was bellow.

{"rows":[{"cdb_cartodbfytable":"test"}],"time":0.068,"fields":{"cdb_cartodbfytable":{"type":"regclass"}},"total_rows":1,"notices":["trigger \"track_updates\" for table \"test\" does not exist, skipping","trigger \"update_the_geom_webmercator_trigger\" for table \"test\" does not exist, skipping","trigger \"test_quota\" for table \"test\" does not exist, skipping","trigger \"test_quota_per_row\" for table \"test\" does not exist, skipping"]}

But the table NEVER appeared on the Datasets dashboard.

2. CARTO Environment

I executed same queries in my CARTO Account(xxx.caro.com) via SQL API, they were finishing successfully with the same message and APPEARED in the dashboard.

4

When you CartoDBfy a table you adapt it to CARTO, but it does not register it in the metadata that the Editor/Builder use to retrieve the list of datasets. This behaviour is what we call "Ghost Tables"

When you go into your Dashboard in CARTO, a Ghost Tables Manager script checks the consistency between the metadata (the user_table and visualization models) and the data in your user database. It registers everything that looks like a proper Carto table and it's not registered already as a User Table.

In order to force this behaviour in your environment, you can go into the Rails console and force the GhostTablesManager to run:

bundle exec rails c development
u = User.find(username:'your_username')
Carto::GhostTablesManager.new(u.id).link_ghost_tables_synchronously

Now, the next time you go into your dashboard you should see your new table.

And, if you're interested, here you can find the GhostTablesManager code: https://github.com/CartoDB/cartodb/blob/3d462fe0569af595760f02740270763ba3b76205/lib/carto/ghost_tables_manager.rb

  • I am able to see new table after running the code! Thanks a lot! – takeho Sep 21 '16 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.