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.
Found an issue in documentation? Write to us.