-
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
36e45bf
816498e
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,35 @@ 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 | ||
|
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. This looks like it resolves to We provide a Map, which is supposed to fill that gap. Maybe you should test that out, and see if it would work as a declared type here? |
||
| assert_results: | ||
| - title: "The Hitchhiker's Guide to the Galaxy" | ||
| author: "Douglas Adams" | ||
| - genre: "Science Fiction" | ||
| year: 1979 | ||
| 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.
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. I think we still need more examples. Both of these are dict-like, so it seems like a pretty basic test. What if someone passes in It would also be good to add some extra stages, to make sure this works like others You can use gemini to create a few extra test scenarios. I usually don't include assert_proto on all of them, because it can be excessive
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. Referring to the golang implementation, the only type accepted is a list of key-value pairs. So I don't think But I think it's a good idea to add more tests. I will also use |
||
| 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
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. Yeah, that should be fine Although we don't support dict constants like this, so maybe change that part at least |
||
|
|
||
| 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) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.