azureazure-digital-twins

Azure Digital Twin forbbitten words in Query


When I execute query

SELECT Group FROM DIGITALTWINS Sensor JOIN Group RELATED Sensor.contains WHERE Sensor.$dtId='xxx’

I'm getting error

RestError: SQL query parse failed: SQL Parser Error, Line=1, Position=7, Message=mismatched input 'Group' expecting {AVG, CONTAINS, COUNT, DEVICES_JOBS, DEVICES_MODULES, DEVICES, DIGITALTWINS, RELATIONSHIPS, JOIN, MAX, MIN, RELATED, SUM, TOP, EXACT, DEFAULT, '*', IDENTIFIER}
SQL Parser Error, Line=1, Position=13, Message=mismatched input 'FROM' expecting BY See samples in http://aka.ms/adtv2query for the correct syntax.

But when I change “Group” to another word, ex “a” Query succeeded. I'm getting this same error when I use the word “Order”. I think this is because this word is used in normal SQL queries, and even if digital twins don't support it, still want to parse it and I got an error.

Where I can find a list of the forbidden words for queries?


Solution

  • Here is the set of "reserved" keywords in the language:

    These words cannot be used as identifiers without enslosing them with [[ ]].

    [UPDATE] See more details in the documentation: https://learn.microsoft.com/en-us/azure/digital-twins/reference-query-reserved