-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(firestore): literals pipeline stage #16028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2a8213c
28acee9
a2e11ed
a97cb13
cc1b737
3861223
7bad13c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -684,4 +684,33 @@ tests: | |
| - args: | ||
| - fieldReferenceValue: awards | ||
| - stringValue: full_replace | ||
| name: replace_with | ||
| name: replace_with | ||
| - description: literals | ||
| pipeline: | ||
| - Literals: | ||
| - title: "The Hitchhiker's Guide to the Galaxy" | ||
| author: "Douglas Adams" | ||
| - Constant: | ||
| value: | ||
| genre: "Science Fiction" | ||
| year: 1979 | ||
| assert_results: | ||
| - title: "The Hitchhiker's Guide to the Galaxy" | ||
| author: "Douglas Adams" | ||
| assert_proto: | ||
| pipeline: | ||
| stages: | ||
| - args: | ||
| - mapValue: | ||
| fields: | ||
| author: | ||
| stringValue: "Douglas Adams" | ||
| title: | ||
| stringValue: "The Hitchhiker's Guide to the Galaxy" | ||
| - mapValue: | ||
| fields: | ||
| genre: | ||
| stringValue: "Science Fiction" | ||
| year: | ||
| integerValue: '1979' | ||
| name: literals | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also have tests here that cover the different input types we support
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! I added additional type to test. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -517,6 +517,35 @@ def test_to_pb(self): | |
| assert len(result.options) == 0 | ||
|
|
||
|
|
||
| class TestLiterals: | ||
| def _make_one(self, *args, **kwargs): | ||
| return stages.Literals(*args, **kwargs) | ||
|
|
||
| def test_ctor(self): | ||
| val1 = Constant.of({"a": 1}) | ||
| val2 = {"b": 2} | ||
| instance = self._make_one(val1, val2) | ||
| assert instance.documents == (val1, val2) | ||
| assert instance.name == "literals" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have tests that cover all supported input types. I don't see anything using str (and looking at go, I'm not sure if we should be supporting str?)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, I don't think we should support str. Here the test includes |
||
|
|
||
| def test_repr(self): | ||
| val1 = Constant.of({"a": 1}) | ||
| instance = self._make_one(val1, {"b": 2}) | ||
| repr_str = repr(instance) | ||
| assert repr_str == "Literals(documents=(Constant.of({'a': 1}), {'b': 2}))" | ||
|
|
||
| def test_to_pb(self): | ||
| val1 = Constant.of({"a": 1}) | ||
| val2 = {"b": 2} | ||
| instance = self._make_one(val1, val2) | ||
| result = instance._to_pb() | ||
| assert result.name == "literals" | ||
| assert len(result.args) == 2 | ||
| assert result.args[0].map_value.fields["a"].integer_value == 1 | ||
| assert result.args[1].map_value.fields["b"].integer_value == 2 | ||
| assert len(result.options) == 0 | ||
|
|
||
|
|
||
| class TestOffset: | ||
| def _make_one(self, *args, **kwargs): | ||
| return stages.Offset(*args, **kwargs) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's been a while since I looked at this, but this doesn't seem like the right syntax to me. Isn't this essentially sending
Literals({"title": ""The Hitchhiker's Guide to the Galaxy", "author", "Douglas Adams"})? That doesn't seem to match thestr | SelectableDoes the test pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does pass. I think
Literalsshould be able to accept dicts, as well as otherExpressiontypes. I have updated the system test to includedictandConstant(a child class ofExpression).