Skip to main content
17-Peridot
January 15, 2024
Solved

Selecting one or more specific fields in query

  • January 15, 2024
  • 1 reply
  • 1606 views

Hello Community,

 

I've been trying to figure out how to use the "select" key in the JSON query functionality of QueryStreamData...

 

me.QueryStreamData({
 // oldestFirst: undefined /* BOOLEAN */,
 // maxItems: undefined /* NUMBER {"defaultValue":500} */,
 // sourceTags: undefined /* TAGS */,
 // endDate: undefined /* DATETIME */,
 // query: undefined /* QUERY */,
 // source: undefined /* STRING */,
 // startDate: undefined /* DATETIME */,
 // tags: undefined /* TAGS */,
 // });

 

However I haven't had any luck...

There is no datashape returned for this service, and even if there was one, I'm not entirely sure I could get it to work.

 

I have do have a datashape for the stream of course, and I did try to use that using the following query:

"select": [
 {
 "dataShapeName": "MyDataShape",
 "fieldName": "FieldName"
 }
]

 But that didn't work either.

 

I also tried just querying everything from my stream and doing an infotable query:

let test = DataShapes["MyDataShape"].CreateValuesWithData({
 values: { values },
 });

 // Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
 let query = {
 "select": [{
 "dataShapeName": "MyDataSHape",
 "fieldName": "FieldName",
 }],
 };

 let params = {
 t: test /* INFOTABLE */,
 query: query /* QUERY */,
 };

 result = Resources["InfoTableFunctions"].Query(params);

 

But this also didn't work... Anyone got any idea of what I am doing wrong?

Or that has done this with success before?

 

Any help would be highly appreciated!

 

Thanks,

Jens C.

Best answer by Rocko

Ah, Operator Advisor, I wondered where you got the "select" idea from. Yeah, that's OA only, different implementation since the OA entities use different templates/classes. RemoveField is probably the easiest solution.

1 reply

Rocko
19-Tanzanite
January 16, 2024

There is no "select" field in the query there is only sorts and filters, as documented in the help topic "Query Parameter for Query Services" as well as in the QueryStreamData Service Info:"Query stream data (no stream entry details), along with filter and sort criteria".

You will get back rows according to the DataShape you assigned to the Stream,

jensc17-PeridotAuthor
17-Peridot
January 16, 2024

Hello @Rocko,

 

Aha, so this only applies to OA?: Link 

 

And there is no other way of getting just one of the columns of a stream that is containing multiple columns?

I guess I'll have to write some service that removes them "manually" with the .RemoveField() function...

 

Thanks though!

Jens C.

Rocko
Rocko19-TanzaniteAnswer
19-Tanzanite
January 16, 2024

Ah, Operator Advisor, I wondered where you got the "select" idea from. Yeah, that's OA only, different implementation since the OA entities use different templates/classes. RemoveField is probably the easiest solution.