File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -152,13 +152,21 @@ class DataClient {
152
152
return response.rawData.map ((e) => BsonCodec .deserialize (BsonBinary .from (e))).toList ();
153
153
}
154
154
155
- /// Obtain unified tabular data and metadata, queried with MQL.
155
+ /// Obtain unified tabular data and metadata, queried with MQL. The query should be of type List<Map<String, dynamic>>.
156
156
///
157
157
/// For more information, see [Data Client API] (https://docs.viam.com/appendix/apis/data-client/).
158
- Future <List <Map <String , dynamic >>> tabularDataByMql (String organizationId, List <Uint8List > query) async {
158
+ Future <List <Map <String , dynamic >>> tabularDataByMql (String organizationId, dynamic query) async {
159
+ List <Uint8List > binary;
160
+ if (query is List <Map <String , dynamic >>) {
161
+ binary = query.map ((q) => BsonCodec .serialize (q).byteList).toList ();
162
+ } else if (query is List <Uint8List >) {
163
+ binary = query;
164
+ } else {
165
+ throw TypeError ();
166
+ }
159
167
final request = TabularDataByMQLRequest ()
160
168
..organizationId = organizationId
161
- ..mqlBinary.addAll (query );
169
+ ..mqlBinary.addAll (binary );
162
170
final response = await _dataClient.tabularDataByMQL (request);
163
171
return response.rawData.map ((e) => BsonCodec .deserialize (BsonBinary .from (e))).toList ();
164
172
}
Original file line number Diff line number Diff line change @@ -162,6 +162,9 @@ void main() {
162
162
});
163
163
164
164
test ('tabularDataByMql' , () async {
165
+ final List <Map <String , dynamic >> query = [
166
+ {'key' : 'value' }
167
+ ];
165
168
final startDate = DateTime .utc (2020 , 12 , 31 );
166
169
final List <Map <String , dynamic >> data = [
167
170
{
@@ -175,7 +178,7 @@ void main() {
175
178
when (serviceClient.tabularDataByMQL (any)).thenAnswer (
176
179
(_) => MockResponseFuture .value (TabularDataByMQLResponse ()..rawData.addAll (data.map ((e) => BsonCodec .serialize (e).byteList))));
177
180
178
- final response = await dataClient.tabularDataByMql ('some_org_id' , [ Uint8List . fromList ( 'some_query' .codeUnits)] );
181
+ final response = await dataClient.tabularDataByMql ('some_org_id' , query );
179
182
expect (response[0 ]['key1' ], equals (data[0 ]['key1' ]));
180
183
expect (response, equals (data));
181
184
});
You can’t perform that action at this time.
0 commit comments