Open andy-esch opened 7 years ago
@andy-esch, nice one you caught here! 💯
First of all, the view
attribute doesn't support variables, so your placeholders won't get substituted with your default values. That means your bounds attribute will be ignored and will fall back to the estimation.
Second, and most important: "it will estimate the extent based on the involved table", the key is the estimate. There are several reasons why the estimation might fail: no tables associated with the query, not stats for the tables, wrong stats on the tables. But none of those is the scenario in your case. Let me explain.
The process is as follows: we compute the tables associated with the layer query, with those tables we calculate the maximum extent using the ST_EstimatedExtent of each table. The problem is, as you pointed, with usernames with hyphens, well not that simple, but with usernames with hyphens for users that belong to multi user accounts (aka organizations). Normal users have their tables in the public
schema. However, organization users have their tables in their own schema, that has the same name as the user.
When we compute the tables associated with the query of the layer, we return the schema name as well to avoid issues with table names collisions and to use the ST_EstimatedExtent(text schema_name, text table_name, text geocolumn_name);
signature. But we return the schema name already quoted if required, so in a non-org user with hyphens, the schema name will be public
, but in an organization user with hyphens, the schema name will be something like "user-name"
, which used in combination with ST_EstimatedExtent
won't work.
I've written all this down so we can investigate further where we should make the proper changes/fixes, as I'm not sure if we should fix it at our application/queries, or ST_EstimatedExtent should handle quoted schema (table) names.
Hey @rochoa
First of all, thanks for the detailed explanation, super useful!!. The second, now that Core Team take care of this kind of issues, do you think it'd be better to open this issue in postgis
' repository?
I have a hunch that the hyphens are the problem here, but I don't know how to look into it very easily so thought I'd open a ticket about my bug hunch. I've seen that on all carto accounts with a hyphen in the username, the cartoframes static map output is zoomed out to the same level, but the un-hyphenated ones behave as expected from the docs:
What seems weird to me, though, is that the default bounding box view is not being used as far as I can tell.
Compare this: https://lwolf-carto.carto.com/api/v1/map/static/named/cartoframes_ver20170406_layers1_time0_baseid1_labels0_zoom0/800/400.png?config=%7B%22sql_0%22%3A+%22SELECT+%2A+FROM+nat%22%7D
to this:
https://ljw.carto.com/api/v1/map/static/named/cartoframes_ver20170406_layers1_time0_baseid1_labels0_zoom0/800/400.png?config=%7B%22sql_0%22%3A+%22SELECT+%2A+FROM+nat%22%7D
It uses the same dataset and same named map template:
cc @rochoa