feat: Add `Rand` and `Trunc` expressions by Linchin · Pull Request #16037 · googleapis/google-cloud-python · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions packages/google-cloud-firestore/tests/system/pipeline_e2e/math.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,89 @@ tests:
- fieldReferenceValue: rating
name: sqrt
name: select
- description: testTrunc
pipeline:
- Collection: books
- Where:
- FunctionExpression.equal_any:
- Field: title
- - Constant: "To Kill a Mockingbird" # rating 4.2
- Constant: "Pride and Prejudice" # rating 4.5
- Constant: "The Lord of the Rings" # rating 4.7
- Select:
- title
- AliasedExpression:
- FunctionExpression.trunc:
- Field: rating
- "trunc_rating"
- AliasedExpression:
- FunctionExpression.trunc:
- Field: rating
- FunctionExpression.add:
- Constant: 0
- Constant: 1
- "trunc_rating_with_places"
- Sort:
- Ordering:
- Field: title
- ASCENDING
assert_results:
- title: "Pride and Prejudice"
trunc_rating: 4.0
trunc_rating_with_places: 4.5
- title: "The Lord of the Rings"
trunc_rating: 4.0
trunc_rating_with_places: 4.7
- title: "To Kill a Mockingbird"
trunc_rating: 4.0
trunc_rating_with_places: 4.2
assert_proto:
pipeline:
stages:
- args:
- referenceValue: /books
name: collection
- args:
- functionValue:
args:
- fieldReferenceValue: title
- functionValue:
args:
- stringValue: "To Kill a Mockingbird"
- stringValue: "Pride and Prejudice"
- stringValue: "The Lord of the Rings"
name: array
name: equal_any
name: where
- args:
- mapValue:
fields:
title:
fieldReferenceValue: title
trunc_rating:
functionValue:
args:
- fieldReferenceValue: rating
name: trunc
trunc_rating_with_places:
functionValue:
args:
- fieldReferenceValue: rating
- functionValue:
args:
- integerValue: '0'
- integerValue: '1'
name: add
name: trunc
name: select
- args:
- mapValue:
fields:
direction:
stringValue: ascending
expression:
fieldReferenceValue: title
name: sort
- description: testRoundFunctionExpressionessions
pipeline:
- Collection: books
Expand Down Expand Up @@ -306,4 +389,49 @@ tests:
- fieldReferenceValue: rating
- integerValue: '2'
name: mod
name: select
- description: testRand
pipeline:
- Collection: books
- Limit: 1
- Select:
- AliasedExpression:
- And:
- FunctionExpression.greater_than_or_equal:
- Rand: []
- Constant: 0.0
- FunctionExpression.less_than:
- Rand: []
- Constant: 1.0
- "is_valid_rand"
assert_results:
- is_valid_rand: true
assert_proto:
pipeline:
stages:
- args:
- referenceValue: /books
name: collection
- args:
- integerValue: '1'
name: limit
- args:
- mapValue:
fields:
is_valid_rand:
functionValue:
name: and
args:
- functionValue:
name: greater_than_or_equal
args:
- functionValue:
name: rand
- doubleValue: 0.0
- functionValue:
name: less_than
args:
- functionValue:
name: rand
- doubleValue: 1.0
name: select
Loading