title | titleSuffix | description | author | ms.author | ms.date | ms.topic | ms.service | ms.custom |
---|---|---|---|---|---|---|---|---|
Query language |
Azure Digital Twins |
Learn about the basics of the Azure Digital Twins query language. |
baanders |
baanders |
02/28/2022 |
conceptual |
digital-twins |
contperf-fy21q2 |
This article describes the basics of the query language and its capabilities. Recall that the center of Azure Digital Twins is the twin graph, constructed from digital twins and relationships. This graph can be queried to get information about the digital twins and relationships it contains. These queries are written in a custom SQL-like query language, referred to as the Azure Digital Twins query language. This language is similar to the IoT Hub query language with many comparable features.
For more detailed examples of query syntax and how to run query requests, see Query the twin graph.
You can use the Azure Digital Twins query language to retrieve digital twins according to their...
- Properties (including tag properties)
- Models
- Relationships
- Properties of the relationships
To submit a query to the service from a client app, you'll use the Azure Digital Twins Query API. One way to use the API is through one of the SDKs for Azure Digital Twins.
[!INCLUDE digital-twins-query-reference.md]
When writing queries for Azure Digital Twins, keep the following considerations in mind:
-
Remember case sensitivity: All Azure Digital Twins query operations are case-sensitive, so take care to use the exact names defined in the models. If property names are misspelled or incorrectly cased, the result set is empty with no errors returned.
-
Escape single quotes: If your query text includes a single quote character in the data, the quote will need to be escaped with the
\
character. Here's an example that deals with a property value of D'Souza::::code language="sql" source="~/digital-twins-docs-samples/queries/examples.sql" id="EscapedSingleQuote":::
[!INCLUDE digital-twins-query-latency-note.md]
The Azure Digital Twins query language is only for querying the present state of your digital twins and relationships.
To run queries on historized digital twin data collected over time, use the data history (preview) feature to connect your Azure Digital Twins instance to an Azure Data Explorer cluster. This will automatically historize digital twin property updates to Azure Data Explorer, where they can be queried using the Azure Digital Twins plugin for Azure Data Explorer.
Learn how to write queries and see client code examples in Query the twin graph.