cacsar
cacsar

Reputation: 2138

Does CosmosDB Graph Api support hasNot?

I'm testing out CosmosDB's Gremlin support and was looking at using hasNot in a query step. According the documentation I can find I see

has - Used to filter properties, vertices, and edges. Supports hasLabel, hasId, hasNot, and has variants.

Working against the default Azure example graph from the Gremlin console I can run

gremlin> :> g.V().has('firstName')

and get reasonable results I would expect yet,

gremlin> :> g.V().hasNot('firstName')

results in the very confidence inspiring stack trace response from Azure (with ids removed just in case).

Gremlin Query Compilation Error: Traversal Script: Failed to compile query:
(1,74): error CS1061: Type `Microsoft.Azure.Graphs.GraphTraversal' does not contain a definition for `hasNot' and no extension method `hasNot' of type `Microsoft.Azure.Graphs.GraphTraversal' could be fou$
d. Are you missing an assembly reference?
D:\local\Temporary ASP.NET Files\root\<removed>\<removed>\assembly\dl3\<removed>\<removed>\Microsoft.Azure.Graphs.dll (Location of the symbol related to previous error)
                ExceptionType : GraphCompileException
                Source : Microsoft.Azure.Graphs
                Context : <removed>
                RequestId : <removed>
                Scope : graphcmd-emitcode
                Status : ScriptEvaluationError
                HResult : 0x80131500
   at Microsoft.Azure.Graphs.Common.MonoTraversalScript.HandleCompileError(Tuple`2& evaluationContext)
   at Microsoft.Azure.Graphs.Common.MonoTraversalScript.Compile()
   at Microsoft.Azure.Graphs.GraphCommand.<ExecuteTraversalAsync>b__38_0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Graphs.GraphCommand.<ExecuteTraversalAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Graphs.GremlinServer.DefaultGraphRequestProcessor.<CreateGremlinResponseInternalAsync>d__13.MoveNext()

The key part is of course that portion of the first line that appears to say that hasNot is not appropriately defined in Azure's .NET dll that's being used to compile the query on the server.

A similar result comes from the query explorer in the dashboard.

This can be worked around (to some extent at least) with

gremlin> :> g.V().not(has('firstName'))

Upvotes: 0

Views: 716

Answers (1)

Oliver Towers
Oliver Towers

Reputation: 445

Unfortunately hasNot() step is currently not exposed on CosmosDB Graph, which looks to be an oversight on our part.

I've added this issue to our backlog, and since it appears to be partially implemented already, it's likely to be available for the next service release (~ 2 weeks).

Upvotes: 1

Related Questions