How to select twins without relations with DTQL

Piotr Radziej 20 Reputation points
2023-06-15T10:15:36.87+00:00

In my case I have a nodes in a graph that are not connected with anything. They doesn't have neither incoming nor outgoing relationships. How to get all of them with single query?
What I did: First get all twins, secondly get all twins that have relationships (with MATCH clause or form relationships collection) and later subtract those two sets - but this approach have other limitations (like not being able to use pagination)

Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
221 questions
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 13,951 Reputation points
    2023-06-15T22:37:07.9333333+00:00

    Hi @Anonymous Greetings! Welcome to Microsoft Q&A forum. Thank you for posting the question here.

    How to get all of them with single query?

    This is interesting use case. The Digital Twin Query language has limitations which prevents usage of Subqueries. Also, with Select from Relationships, you cannot use join clause with it. With these limitations, I don't think it would be possible to form a single query to fetch the desired result. Please refer to the Limitations page of Digital Query for this information.

    Perhaps you can try extracting$dtid using the query SELECT $sourceId,$targetId FROM RELATIONSHIPS and use SELECT * FROM DIGITALTWINS WHERE NOT ($dtId IN ['id1', 'id2']) to get all the Digital Twins without a relationship. I haven't tested this completely and it might be complicated to get a list of distinct $dtId from first query and pass it on as values to the NOT-IN query. But, with this approach we perhaps can get a Pageable result.

    You can provide product feedback using the following link and share the details to support complex querying using Azure Digital Twin Query language. Kindly share the feature link once you create so that other community members facing similar challenge can upvote the featrure request.

    Hope this helps. Please let us know if you have any additional questions or need further assistance on this.


    If the response helped, please do click Accept Answer and Yes Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    0 comments No comments

0 additional answers

Sort by: Most helpful