from cognite.client.data_classes.data_modeling.query import Query, Select, NodeResultSetExpression, EdgeResultSetExpression, SourceSelector
from cognite.client.data_classes.filters import Range, Equals
from cognite.client.data_classes.data_modeling.ids import ViewId
movie_id = ViewId("mySpace", "MovieView", "v1")
actor_id = ViewId("mySpace", "ActorView", "v1")
query = Query(
with_ = {
"movies": NodeResultSetExpression(filter=Range(movie_id.as_property_ref("releaseYear"), lt=2000)),
"actors_in_movie": EdgeResultSetExpression(from_="movies", filter=Equals(["edge", "type"], {"space": movie_id.space, "externalId": "Movie.actors"})),
"actors": NodeResultSetExpression(from_="actors_in_movie"),
},
select = {
"actors": Select(
[SourceSelector(actor_id, ["name"])], sort=[InstanceSort(actor_id.as_property_ref("name"))]),
},
)
res = client.data_modeling.instances.query(query)
from cognite.client.data_classes.data_modeling.data_types import UnitReference, UnitSystemReference
selected_source = SourceSelector(
source=ViewId("my-space", "my-xid", "v1"),
properties=["f32_prop1", "f32_prop2", "f64_prop1", "f64_prop2"],
target_units=[
TargetUnit("f32_prop1", UnitReference("pressure:kilopa")),
TargetUnit("f32_prop2", UnitReference("pressure:barg")),
TargetUnit("f64_prop1", UnitSystemReference("SI")),
TargetUnit("f64_prop2", UnitSystemReference("Imperial")),
],
)
SourceSelector(source=ViewId("my-space", "my-xid", "v1"), properties=["*"]){
"items": {},
"nextCursor": {},
"typing": {},
"debug": {
"notices": [
{
"code": "excessiveTimeout",
"category": "invalidDebugOptions",
"level": "warning",
"hint": "<string>",
"timeout": 123
}
],
"translatedQuery": {
"query": {},
"parameters": {}
},
"plan": {
"fullPlan": {},
"profiled": true,
"byIdentifier": {}
},
"llmPrompt": "<string>"
}
}Required capabilities:
DataModelsAcl:READ
Specification of query endpoint. For more information, see Query language.
from cognite.client.data_classes.data_modeling.query import Query, Select, NodeResultSetExpression, EdgeResultSetExpression, SourceSelector
from cognite.client.data_classes.filters import Range, Equals
from cognite.client.data_classes.data_modeling.ids import ViewId
movie_id = ViewId("mySpace", "MovieView", "v1")
actor_id = ViewId("mySpace", "ActorView", "v1")
query = Query(
with_ = {
"movies": NodeResultSetExpression(filter=Range(movie_id.as_property_ref("releaseYear"), lt=2000)),
"actors_in_movie": EdgeResultSetExpression(from_="movies", filter=Equals(["edge", "type"], {"space": movie_id.space, "externalId": "Movie.actors"})),
"actors": NodeResultSetExpression(from_="actors_in_movie"),
},
select = {
"actors": Select(
[SourceSelector(actor_id, ["name"])], sort=[InstanceSort(actor_id.as_property_ref("name"))]),
},
)
res = client.data_modeling.instances.query(query)
from cognite.client.data_classes.data_modeling.data_types import UnitReference, UnitSystemReference
selected_source = SourceSelector(
source=ViewId("my-space", "my-xid", "v1"),
properties=["f32_prop1", "f32_prop2", "f64_prop1", "f64_prop2"],
target_units=[
TargetUnit("f32_prop1", UnitReference("pressure:kilopa")),
TargetUnit("f32_prop2", UnitReference("pressure:barg")),
TargetUnit("f64_prop1", UnitSystemReference("SI")),
TargetUnit("f64_prop2", UnitSystemReference("Imperial")),
],
)
SourceSelector(source=ViewId("my-space", "my-xid", "v1"), properties=["*"]){
"items": {},
"nextCursor": {},
"typing": {},
"debug": {
"notices": [
{
"code": "excessiveTimeout",
"category": "invalidDebugOptions",
"level": "warning",
"hint": "<string>",
"timeout": 123
}
],
"translatedQuery": {
"query": {},
"parameters": {}
},
"plan": {
"fullPlan": {},
"profiled": true,
"byIdentifier": {}
},
"llmPrompt": "<string>"
}
}Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Query specification.
Show child attributes
Select properties for each result set.
Show child attributes
Cursors returned from the previous query request. These cursors match the result set expressions you specified in the with clause for the query.
Show child attributes
Values in filters can be parameterised. Parameters are provided as part of the query object, and referenced in the filter itself.
Show child attributes
Should we return property type information as part of the result?
Return query debug notices.
Show child attributes
Matching nodes and edges
Was this page helpful?