Gremlin API of Cosmos DB Emulator fails to parse decimal numbers

Quinten Claes 40 Reputation points
Oct 8, 2024, 11:38 AM

I'm currently developing an application using the Gremlin API of an Azure Cosmos DB, utilizing the Cosmos DB Emulator for local development as per the documentation. However, I've encountered an issue where the emulator does not handle decimal numbers correctly.

gremlin> g.V('').inject(100.0D).fold()
==>[1000.0]
gremlin> g.V('').inject(123.45D).fold()
==>[12345.0]
gremlin> g.V('').inject(123.45).fold()
==>[12345.0]

The emulator's Gremlin API ignores the decimal values and stores them as whole numbers. In the examples above, the value 100.0D is stored as 1000.0, and 123.45D or 123.45 is stored as 12345.0. Testing on a live Cosmos DB instance this is not an issue.

I would appreciate any insights on how to resolve this issue with the Cosmos DB Emulator.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,718 questions
{count} votes

Accepted answer
  1. Oury Ba-MSFT 19,991 Reputation points Microsoft Employee
    Oct 10, 2024, 10:00 PM

    @Quinten Claes

    Thank you for confirming the issue is resolved by doing the below steps.

    Actions Taken

    By changing my system's regional settings to en-US.

    $env:DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = 1

    Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator" $startEmulatorCmd = "Start-CosmosDbEmulator -EnableGremlin -GremlinPort 65400" Invoke-Expression -Command $startEmulatorCmd

    Reference: https://github.com/Azure/cosmos-explorer/issues/1860

    Please don't forget to mark as accept answer so this will be easily found by community members with the same question.

    Regards,

    Oury

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Quinten Claes 40 Reputation points
    Oct 10, 2024, 8:09 AM

    Hi @Oury Ba-MSFT , that was indeed the issue for me as well. Thanks a lot for your support.

    For anyone interested, the issue was that my computer has a locale configured which uses "," for decimal point instead of ".". Starting the emulator with the following powershell script works around that issue as Florent-LAVAUD explains in the Github issue:

    $env:DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = 1
    Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
    $startEmulatorCmd = "Start-CosmosDbEmulator -EnableGremlin -GremlinPort 65400"
    Invoke-Expression -Command $startEmulatorCmd
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.