azure-cosmos-db-emulator-docker icon indicating copy to clipboard operation
azure-cosmos-db-emulator-docker copied to clipboard

Queris fail when document properties are compared.

Open kamnel opened this issue 7 months ago • 0 comments

Describe the bug The new linux emulator (cosmosEmulatorVnextPreview) is unable to execute queries that compare document properties. These queries work fin in Windows version of emulator

To Reproduce Steps to reproduce the behavior:

  1. Start Comos emulator vNext
  2. Add a database and collection using cosmos explorer
  3. Add the following item
{
    "id": "d624842e-6753-47e6-9b42-5d78cfc7036a",
    "Name": "John Doe",
    "Type": "User",
    "UserId": "user0001",
    "TenantCode": "tenant1",
    "PrimaryTenantCode": "tenant1"
}
  1. Execute the following query:
SELECT c FROM root c WHERE c.Type = "User" AND c.TenantCode = c.PrimaryTenantCode
  1. The query does not complete and you get the error
Failed to query item for container users:
 System.NotSupportedException: There is no support for non scalar 
   at Microsoft.Azure.Cosmos.Postgres.Core.Query.SqlObjectPGTextSerializer.Visit(SqlBinaryScalarExpression sqlObject) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjectPGTextSerializer.cs:line 209
   at Microsoft.Azure.Cosmos.SqlObjects.SqlBinaryScalarExpression.Accept(SqlObjectVisitor visitor) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjects/SqlBinaryScalarExpression.cs:line 39
   at Microsoft.Azure.Cosmos.Postgres.Core.Query.SqlObjectPGTextSerializer.ProcessBinaryScalarExpression(SqlScalarExpression leftExpression, SqlScalarExpression rightExpression, SqlBinaryScalarOperatorKind operatorKind) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjectPGTextSerializer.cs:line 223
   at Microsoft.Azure.Cosmos.Postgres.Core.Query.SqlObjectPGTextSerializer.Visit(SqlBinaryScalarExpression sqlObject) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjectPGTextSerializer.cs:line 195
   at Microsoft.Azure.Cosmos.SqlObjects.SqlBinaryScalarExpression.Accept(SqlObjectVisitor visitor) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjects/SqlBinaryScalarExpression.cs:line 39
   at Microsoft.Azure.Cosmos.Postgres.Core.Query.SqlObjectPGTextSerializer.Visit(SqlWhereClause sqlObject) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjectPGTextSerializer.cs:line 1135
   at Microsoft.Azure.Cosmos.Postgres.Core.Query.SqlObjectPGTextSerializer.Visit(SqlQuery sqlObject) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjectPGTextSerializer.cs:line 882
   at Microsoft.Azure.Cosmos.SqlObjects.SqlQuery.Accept(SqlObjectVisitor visitor) in /tmp/gateway/Cosmos.Postgres.Core/Query/SqlObjects/SqlQuery.cs:line 48
   at Microsoft.Azure.Cosmos.Postgres.Core.Interop.SqlOperationHandler.HandleQueryRequestAsync(SqlRequest request, PostgresClient client, SqlQuerySpec querySpec, CancellationToken cancellation) in /tmp/gateway/Cosmos.Postgres.Core/Interop/SqlOperationHandler.cs:line 462
   at Microsoft.Azure.Cosmos.Postgres.Core.Interop.SqlOperationHandler.ProcessRequestAsync(SqlRequest request, PostgresClient client) in /tmp/gateway/Cosmos.Postgres.Core/Interop/SqlOperationHandler.cs:line 61
   at Microsoft.Azure.Cosmos.Postgres.Core.Interop.SqlRequestPipeline.ProcessRequestAsync(KestrelHttpRequestContext transportRequest) in /tmp/gateway/Cosmos.Postgres.Core/Interop/SqlRequestPipeline.cs:line 56

Expected behavior The query is supposed to complete successfully and the document added earlier is returned as the result.

Additional context The query SELECT c FROM root c WHERE c.Type = "User" where properties are not compared executes correctly, the issue appears to be when we try to compare document properties like SELECT c FROM root c WHERE c.TenantCode = c.PrimaryTenantCode

kamnel avatar Apr 08 '25 22:04 kamnel