CartoDB/cartoframes

Missing space in VariableFilter where clause construction

Closed this issue · 4 comments

where = 'WHERE {}'.format('AND '.join(where_clausules))

If we add a space before the AND it might take care of an error I get when trying to apply two VariableFilters:

[{'reason': 'invalidQuery', 'location': 'query', 'message': 'Syntax error: Missing whitespace between literal and alias at [32:65]'}]

Here's my code:

enriched_data = enrich.enrich_polygons(
    polys,
    variables=dataset_vars,
    filters=[
        VariableFilter(
            Variable.get("date_range_star_d1bbce15"), "= 1567296000 "
        ),
        VariableFilter(dataset_vars[-1], " is not null "),
    ],
    aggregation={dataset_vars[-1].id: "ARRAY_AGG"},
)

If I add spaces around the filter condition in the VariableFilter it works just fine but when I remove the spaces that error shows up.

For example:

# this works
    filters=[
        VariableFilter(
            Variable.get("date_range_star_d1bbce15"), "= 1567296000 "
        ),
        VariableFilter(dataset_vars[-1], " is not null "),
    ],
# this doesn't work
    filters=[
        VariableFilter(
            Variable.get("date_range_star_d1bbce15"), "= 1567296000"
        ),
        VariableFilter(dataset_vars[-1], "is not null"),
    ],

This could be solved with #1397.

cc @oleurud.

🚀 It should be solved. Take into account #1406

@andy-esch could you check this issue has been solved?

Already solved