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

AppEngine: number of returned result does not match downsample_to when default limit is reached #824

Closed
Annopaolo opened this issue Jul 21, 2023 · 1 comment
Labels
API This issue or pull request is about API (e.g. unclear API, new API, API change, deprecation) app:appengine_api This issue or pull request is about astarte_appengine_api application AppEngine API v2 This issue or pull request is about the new AppEngine API (v2) user experience This issue is about user experience
Milestone

Comments

@Annopaolo
Copy link
Collaborator

Annopaolo commented Jul 21, 2023

If a device has sent more data than the default query limit (i.e. 10000), if the following query is performed:

curl -X GET -H "Authorization: Bearer $JWT" \
        "http://$ASTARTE_HOST/appengine/v1/$REALM/devices/$DEVICE_ID/interfaces/org.astarte-platform.genericsensors.Values/streamTest/value?downsample_to=100"

The number of returned results is strictly lower than the downsample_to value. Also, the number of returned samples decreases as the total sample count increases.
If the limit parameter is specified, the number of returned results does match downsample_to, i.e. the following query

curl -X GET -H "Authorization: Bearer $JWT" \
       "http://$ASTARTE_HOST/appengine/v1/$REALM/devices/$DEVICE_ID/interfaces/org.astarte-platform.genericsensors.Values/streamTest/value?downsample_to=100&limit=200"

correctly returns 100 samples. However, if limit > 10000, the incorrect behavior comes back.

This could be due to the fact that two queries are performed: one for retrieving actual data, and one to count the number of returned samples. See

values_query =
DatabaseQuery.new()
|> DatabaseQuery.statement(values_query_statement)
|> DatabaseQuery.put(:device_id, device_id)
|> DatabaseQuery.put(:interface_id, interface_row[:interface_id])
|> DatabaseQuery.put(:endpoint_id, endpoint_id)
|> DatabaseQuery.put(:path, path)
|> DatabaseQuery.merge(q_params)
values = DatabaseQuery.call!(client, values_query)
count_query =
values_query
|> DatabaseQuery.statement(count_query_statement)
count = get_results_count(client, count_query, opts)
{:ok, count, values}

There have been some issues in Cassandra regarding the behavior of the LIMIT param together with count() (see e.g. https://issues.apache.org/jira/browse/CASSANDRA-8216?focusedCommentId=15235570&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-15235570).

When the actual issue is fixed, it would be great to thoroughly document the expected behaviour ( #629 👀).

@Annopaolo Annopaolo added user experience This issue is about user experience API This issue or pull request is about API (e.g. unclear API, new API, API change, deprecation) app:appengine_api This issue or pull request is about astarte_appengine_api application AppEngine API v2 This issue or pull request is about the new AppEngine API (v2) labels Jul 21, 2023
@Annopaolo Annopaolo added this to the v1.3 milestone Jul 21, 2023
@Annopaolo
Copy link
Collaborator Author

Closed by #827.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API This issue or pull request is about API (e.g. unclear API, new API, API change, deprecation) app:appengine_api This issue or pull request is about astarte_appengine_api application AppEngine API v2 This issue or pull request is about the new AppEngine API (v2) user experience This issue is about user experience
Projects
Status: Done
Development

No branches or pull requests

1 participant