Skip to content

Commit 6f61f78

Browse files
committed
added subcollections to test yaml
1 parent 4d58a44 commit 6f61f78

File tree

3 files changed

+118
-2
lines changed

3 files changed

+118
-2
lines changed

packages/google-cloud-firestore/tests/system/pipeline_e2e/data.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,27 @@ data:
144144
doc_with_nan:
145145
value: "NaN"
146146
doc_with_null:
147-
value: null
147+
value: null
148+
cities:
149+
city1:
150+
name: "San Francisco"
151+
city2:
152+
name: "New York"
153+
"cities/city1/landmarks":
154+
lm1:
155+
name: "Golden Gate Bridge"
156+
type: "Bridge"
157+
lm2:
158+
name: "Alcatraz"
159+
type: "Island"
160+
"cities/city2/landmarks":
161+
lm3:
162+
name: "Statue of Liberty"
163+
type: "Monument"
164+
"cities/city1/landmarks/lm1/reviews":
165+
rev1:
166+
author: "Alice"
167+
rating: 5
168+
rev2:
169+
author: "Bob"
170+
rating: 4

packages/google-cloud-firestore/tests/system/pipeline_e2e/subqueries.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,96 @@ tests:
189189
- Collection: books
190190
- bad_scalar
191191
assert_error: ".*multiple results.*"
192+
193+
- description: subcollection_array_subquery_missing
194+
pipeline:
195+
- Collection: books
196+
- Limit: 1
197+
- Define:
198+
- AliasedExpression:
199+
- CurrentDocument:
200+
- p
201+
- Select:
202+
- AliasedExpression:
203+
- Pipeline.to_array_expression:
204+
- Subcollection: does_not_exist
205+
- Select:
206+
- AliasedExpression:
207+
- Variable: p
208+
- sub_p
209+
- missing_data
210+
assert_results:
211+
- missing_data: []
212+
213+
- description: subcollection_array_subquery_landmarks
214+
pipeline:
215+
- Collection: cities
216+
- Where:
217+
- FunctionExpression.equal:
218+
- Field: name
219+
- Constant: "San Francisco"
220+
- Select:
221+
- Field: name
222+
- AliasedExpression:
223+
- Pipeline.to_array_expression:
224+
- Subcollection: landmarks
225+
- Select:
226+
- Field: name
227+
- Field: type
228+
- Sort:
229+
- Ordering:
230+
- Field: name
231+
- ASCENDING
232+
- landmarks_data
233+
assert_results:
234+
- name: "San Francisco"
235+
landmarks_data:
236+
- name: "Alcatraz"
237+
type: "Island"
238+
- name: "Golden Gate Bridge"
239+
type: "Bridge"
240+
241+
- description: subcollection_array_subquery_reviews
242+
pipeline:
243+
- Collection: cities
244+
- Where:
245+
- FunctionExpression.equal:
246+
- Field: name
247+
- Constant: "San Francisco"
248+
- Limit: 1
249+
- Define:
250+
- AliasedExpression:
251+
- CurrentDocument:
252+
- city_doc
253+
- Select:
254+
- Field: name
255+
- AliasedExpression:
256+
- Pipeline.to_array_expression:
257+
- Subcollection: landmarks
258+
- Where:
259+
- FunctionExpression.equal:
260+
- Field: name
261+
- Constant: "Golden Gate Bridge"
262+
- Select:
263+
- Field: name
264+
- AliasedExpression:
265+
- Pipeline.to_array_expression:
266+
- Subcollection: reviews
267+
- Select:
268+
- Field: author
269+
- Field: rating
270+
- Sort:
271+
- Ordering:
272+
- Field: author
273+
- ASCENDING
274+
- review_data
275+
- landmark_with_reviews
276+
assert_results:
277+
- name: "San Francisco"
278+
landmark_with_reviews:
279+
- name: "Golden Gate Bridge"
280+
review_data:
281+
- author: "Alice"
282+
rating: 5
283+
- author: "Bob"
284+
rating: 4

packages/google-cloud-firestore/tests/system/test_pipeline_acceptance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def _parse_yaml_types(data):
354354
return {key: _parse_yaml_types(value) for key, value in data.items()}
355355
if isinstance(data, list):
356356
# detect vectors
357-
if all([isinstance(d, float) for d in data]):
357+
if len(data) > 0 and all([isinstance(d, float) for d in data]):
358358
return Vector(data)
359359
else:
360360
return [_parse_yaml_types(value) for value in data]

0 commit comments

Comments
 (0)