azure-sdk-for-cpp icon indicating copy to clipboard operation
azure-sdk-for-cpp copied to clipboard

`QueryEntitiesPagedResponse::MoveToNextPage()` in Data Table SDK doesn't work

Open krzwaraksa opened this issue 1 year ago • 2 comments

QueryEntitiesPagedResponse::MoveToNextPage() method in Azure Data Tables C++ SDK doesn't move to next page. The reason is probably a bug in QueryEntitiesPagedResponse::OnNextPage() method - NextPartitionKey is set to PartitionKey. In QueryEntities(). PartitionKey is set to PartitionKey in URL, but NextPartitionKey from response should be set to NextPartitionKey in the URL, as per documentation: https://learn.microsoft.com/en-us/rest/api/storageservices/query-timeout-and-pagination.

To Reproduce Steps to reproduce the behavior:

  • run below code snippet

Code Snippet

#include <iostream>
#include <azure/data/tables.hpp>
#include <azure/identity/default_azure_credential.hpp>

int main() {
  const std::string tableName = "<your table name>";
  const std:: string storageUrl = "<your storage account URL>";

  auto cred = std::make_shared<Azure::Identity::DefaultAzureCredential>();
  auto tableClient = Azure::Data::Tables::TableClient(
      storageUrl , tableName, cred);

  for (int i = 0; i < 1010; i++)
  {
    auto entity = Azure::Data::Tables::Models::TableEntity();
    entity.SetPartitionKey("partition");
    entity.SetRowKey("rowKey" + std::to_string(i));
    tableClient.AddEntity(entity);
  }

  Azure::Data::Tables::Models::QueryEntitiesOptions options;
  auto response = tableClient.QueryEntities(options);
  std::cout << "number of entities: " << response.TableEntities.size(); // 1000, OK
  std::cout << "first entity row key: " << response.TableEntities[0].GetRowKey().Value; // rowKey0, OK
  std::cout << "last entity row key: " << response.TableEntities.back().GetRowKey().Value; // rowKey99, OK
  
  response.MoveToNextPage();
  std::cout << "number of entities: " << response.TableEntities.size(); // Wrong, got 1000, expected 10
  std::cout << "first entity row key: " << response.TableEntities[0].GetRowKey().Value; // Wrong, got 0, expected rowKey990
  std::cout << "last entity row key: " << response.TableEntities.back().GetRowKey().Value; // Wrong, got 99, expected rowKey999
}

Expected behavior MoveToNextPage() should move pages, as shown in the code snippet.

Setup

  • OS: WSL, Ubuntu 22.04
  • IDE : VS Code
  • Version of the Library used: azure-data-tables-cpp, 1.0.0-beta.2 (pulled from VCPKG)

krzwaraksa avatar May 13 '24 09:05 krzwaraksa

Thank you for your feedback. Tagging and routing to the team member best able to assist.

github-actions[bot] avatar May 13 '24 09:05 github-actions[bot]

Thank you for the report, looking into it.

gearama avatar May 14 '24 17:05 gearama