What is the fastest way to get the first row of a DataMartQueryResult as map?
Question
What is the fastest way to get the first row of a DataMartQueryResult as map?
Best I've found is this, but seems inefficient to convert between so many types first:
dmctx.executeQuery(q).getData().toResultMatrix().getEntries().getAt(0)
Answer
Use this:
for (def row : dmctx.executeQuery(q)?.data) {
// row is a map of {field,value} pairs
}
The field is then actually the projection name, so you can set up some very concise code like this.
, multiple selections available,
Related content
How to Format Datamart Query Results
How to Format Datamart Query Results
More like this
Datamart Query Expressions
Datamart Query Expressions
Read with this
How to Query a Data Source Directly
How to Query a Data Source Directly
More like this
Can I query a Data Source directly?
Can I query a Data Source directly?
More like this
Why is SUM not working on Datamart query
Why is SUM not working on Datamart query
Read with this
How do I get the whole row object within an element of a calculation logic?
How do I get the whole row object within an element of a calculation logic?
More like this
Found an issue in documentation? Write to us.