vscode-cosmosdb icon indicating copy to clipboard operation
vscode-cosmosdb copied to clipboard

NoSQL Query Editor shows empty result

Open bk201- opened this issue 1 year ago • 4 comments

How to reproduce:

  • Connect to collection which has only 10 documents
  • Change Page size to 10 in toolbar
  • Run query SELECT * FROM c
  • Click on Go to the next page

Expected:

  • Button is disabled, since collection has only 10 records and all of them were shown

Actual:

  • Button is enabled
  • Second page shows No data to display

Additional:

  • If run query SELECT TOP 10 * FROM c the button is disabled

bk201- avatar Nov 20 '24 12:11 bk201-

@bk201- is this an issue with the SDK? Or why the external tag?

sevoku avatar Mar 21 '25 08:03 sevoku

@sajeetharan Could you please take a look? The container has only 10 records, when I run query I create the iterator and call fetchNext(). I set the following options for iterator

  this.iterator = client
      .database(this.databaseId)
      .container(this.containerId)
      .items.query<QueryResultRecord>(this.query, {
          abortSignal: this.abortController.signal,
          populateQueryMetrics: true,
          populateIndexMetrics: true,
          maxItemCount: isFetchAll // false
              ? undefined
              : (this.resultViewMetadata?.countPerPage ?? DEFAULT_PAGE_SIZE), // I want to receive only 10 therfore set this to 10 
          maxDegreeOfParallelism: 1000,
          bufferItems: true,
          forceQueryPlan: true,
      });

In response I see that hasMoreResults is true, however container has only 10 records, it should be false.

bk201- avatar Jul 24 '25 13:07 bk201-

@bk201- which SDK version is getting used? Could you share with us a repro scenario? (Tell us the container config - number of partitions)

amanrao23 avatar Oct 23 '25 07:10 amanrao23

@amanrao23 Sorry, missed your message. SDK - any v4, I 100% sure that this behavior has been repeated since v4.3, at actual v4.7 the same error. If you have access to subscription cosmosdb-portalteam-generaltest-msft you can find there resource group rg-dshilov-test then dshil-nosql-01 then database ToDoList then container PartitionKey_3. There are exactly 10 records. Then call

client
      .database('ToDoList')
      .container('PartitionKey_3')
      .items.query<QueryResultRecord>('SELECT * FROM c', {
          populateQueryMetrics: true,
          populateIndexMetrics: true,
          maxItemCount: 10,
          maxDegreeOfParallelism: 1000,
          bufferItems: true,
          forceQueryPlan: true,
      }).fetchNext()

In the response the hasMoreResults will be true. if I'm not mistaken due to continuationToke (if it exists then hasMoreResults is true).

bk201- avatar Nov 18 '25 16:11 bk201-