Skip to content

Commit c3eb82c

Browse files
committed
removed parent and reference_slice
1 parent a2e6454 commit c3eb82c

File tree

4 files changed

+49
-176
lines changed

4 files changed

+49
-176
lines changed

packages/google-cloud-firestore/google/cloud/firestore_v1/pipeline_expressions.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,19 +1149,6 @@ def switch_on(
11491149
)
11501150
return FunctionExpression("switch_on", args)
11511151

1152-
@expose_as_static
1153-
def parent(self) -> "Expression":
1154-
"""Creates an expression that returns the parent document of a document reference.
1155-
1156-
Example:
1157-
>>> # Get the parent document of a document reference.
1158-
>>> Field.of("__name__").parent()
1159-
1160-
Returns:
1161-
An Expression representing that returns a reference to the parent document.
1162-
"""
1163-
return FunctionExpression("parent", [self])
1164-
11651152
@expose_as_static
11661153
def storage_size(self) -> "Expression":
11671154
"""Calculates the Firestore storage size of a given value.
@@ -1176,29 +1163,6 @@ def storage_size(self) -> "Expression":
11761163
"""
11771164
return FunctionExpression("storage_size", [self])
11781165

1179-
@expose_as_static
1180-
def reference_slice(
1181-
self, offset: int | Expression, length: int | Expression
1182-
) -> "Expression":
1183-
"""Extracts a slice of the path segments from a document reference.
1184-
1185-
Example:
1186-
>>> Field.of("__name__").reference_slice(1, 2)
1187-
1188-
Args:
1189-
offset: The starting index of the path segment.
1190-
length: The number of segments to include in the slice.
1191-
1192-
Returns:
1193-
A new `Expression` that returns a reference to the sliced portion of the document path.
1194-
"""
1195-
args = [
1196-
self,
1197-
self._cast_to_expr_or_convert_to_constant(offset),
1198-
self._cast_to_expr_or_convert_to_constant(length),
1199-
]
1200-
return FunctionExpression("reference_slice", args)
1201-
12021166
@expose_as_static
12031167
def sum(self) -> "Expression":
12041168
"""Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs.

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

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -295,53 +295,6 @@ tests:
295295
- Pipeline:
296296
- Collection: books
297297
assert_count: 20 # Results will be duplicated
298-
- description: testDocumentId
299-
pipeline:
300-
- Collection: books
301-
- Where:
302-
- FunctionExpression.equal:
303-
- Field: title
304-
- Constant: "The Hitchhiker's Guide to the Galaxy"
305-
- Select:
306-
- AliasedExpression:
307-
- FunctionExpression.document_id:
308-
- Field: __name__
309-
- "doc_id"
310-
assert_results:
311-
- doc_id: "book1"
312-
assert_proto:
313-
pipeline:
314-
stages:
315-
- args:
316-
- referenceValue: /books
317-
name: collection
318-
- args:
319-
- functionValue:
320-
args:
321-
- fieldReferenceValue: title
322-
- stringValue: "The Hitchhiker's Guide to the Galaxy"
323-
name: equal
324-
name: where
325-
- args:
326-
- mapValue:
327-
fields:
328-
doc_id:
329-
functionValue:
330-
name: document_id
331-
args:
332-
- fieldReferenceValue: __name__
333-
name: select
334-
- description: testCollectionId
335-
pipeline:
336-
- Collection: books
337-
- Limit: 1
338-
- Select:
339-
- AliasedExpression:
340-
- FunctionExpression.collection_id:
341-
- Field: __name__
342-
- "collectionName"
343-
assert_results:
344-
- collectionName: "books"
345298
- description: testCollectionGroup
346299
pipeline:
347300
- CollectionGroup: books
@@ -794,35 +747,6 @@ tests:
794747
- res
795748
assert_results:
796749
- res: "B"
797-
- description: testParent
798-
pipeline:
799-
- Collection: books
800-
- Limit: 1
801-
- Select:
802-
- AliasedExpression:
803-
- FunctionExpression.parent:
804-
- Field: __name__
805-
- res
806-
assert_results:
807-
- res: "/books/book1"
808-
assert_proto:
809-
pipeline:
810-
stages:
811-
- args:
812-
- referenceValue: /books
813-
name: collection
814-
- args:
815-
- integerValue: '1'
816-
name: limit
817-
- args:
818-
- mapValue:
819-
fields:
820-
res:
821-
functionValue:
822-
args:
823-
- fieldReferenceValue: __name__
824-
name: parent
825-
name: select
826750
- description: testStorageSize
827751
pipeline:
828752
- Collection: books
@@ -852,47 +776,3 @@ tests:
852776
- fieldReferenceValue: __name__
853777
name: storage_size
854778
name: select
855-
- description: testReferenceSlice
856-
pipeline:
857-
- Collection: books
858-
- Where:
859-
- FunctionExpression.equal:
860-
- Field: title
861-
- Constant: "1984"
862-
- Select:
863-
- AliasedExpression:
864-
- FunctionExpression.document_id:
865-
- FunctionExpression.reference_slice:
866-
- Field: __name__
867-
- Constant: 0
868-
- Constant: 1
869-
- res
870-
assert_results:
871-
- res: "book8"
872-
assert_proto:
873-
pipeline:
874-
stages:
875-
- args:
876-
- referenceValue: /books
877-
name: collection
878-
- args:
879-
- functionValue:
880-
args:
881-
- fieldReferenceValue: title
882-
- stringValue: '1984'
883-
name: equal
884-
name: where
885-
- args:
886-
- mapValue:
887-
fields:
888-
res:
889-
functionValue:
890-
args:
891-
- functionValue:
892-
args:
893-
- fieldReferenceValue: __name__
894-
- integerValue: '0'
895-
- integerValue: '1'
896-
name: reference_slice
897-
name: document_id
898-
name: select
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
tests:
2+
- description: testDocumentId
3+
pipeline:
4+
- Collection: books
5+
- Where:
6+
- FunctionExpression.equal:
7+
- Field: title
8+
- Constant: "The Hitchhiker's Guide to the Galaxy"
9+
- Select:
10+
- AliasedExpression:
11+
- FunctionExpression.document_id:
12+
- Field: __name__
13+
- "doc_id"
14+
assert_results:
15+
- doc_id: "book1"
16+
assert_proto:
17+
pipeline:
18+
stages:
19+
- args:
20+
- referenceValue: /books
21+
name: collection
22+
- args:
23+
- functionValue:
24+
args:
25+
- fieldReferenceValue: title
26+
- stringValue: "The Hitchhiker's Guide to the Galaxy"
27+
name: equal
28+
name: where
29+
- args:
30+
- mapValue:
31+
fields:
32+
doc_id:
33+
functionValue:
34+
name: document_id
35+
args:
36+
- fieldReferenceValue: __name__
37+
name: select
38+
- description: testCollectionId
39+
pipeline:
40+
- Collection: books
41+
- Limit: 1
42+
- Select:
43+
- AliasedExpression:
44+
- FunctionExpression.collection_id:
45+
- Field: __name__
46+
- "collectionName"
47+
assert_results:
48+
- collectionName: "books"
49+

packages/google-cloud-firestore/tests/unit/v1/test_pipeline_expressions.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -949,15 +949,6 @@ def test_switch_on(self):
949949
infix_instance = arg1.switch_on(arg2, arg3, arg4, arg5)
950950
assert infix_instance == instance
951951

952-
def test_parent(self):
953-
arg1 = self._make_arg("Input")
954-
instance = Expression.parent(arg1)
955-
assert instance.name == "parent"
956-
assert instance.params == [arg1]
957-
assert repr(instance) == "Input.parent()"
958-
infix_instance = arg1.parent()
959-
assert infix_instance == instance
960-
961952
def test_storage_size(self):
962953
arg1 = self._make_arg("Input")
963954
instance = Expression.storage_size(arg1)
@@ -967,17 +958,6 @@ def test_storage_size(self):
967958
infix_instance = arg1.storage_size()
968959
assert infix_instance == instance
969960

970-
def test_reference_slice(self):
971-
arg1 = self._make_arg("Input")
972-
arg2 = self._make_arg("Offset")
973-
arg3 = self._make_arg("Length")
974-
instance = Expression.reference_slice(arg1, arg2, arg3)
975-
assert instance.name == "reference_slice"
976-
assert instance.params == [arg1, arg2, arg3]
977-
assert repr(instance) == "Input.reference_slice(Offset, Length)"
978-
infix_instance = arg1.reference_slice(arg2, arg3)
979-
assert infix_instance == instance
980-
981961
def test_not(self):
982962
arg1 = self._make_arg("Condition")
983963
instance = expr.Not(arg1)

0 commit comments

Comments
 (0)