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
ingest: dot_expander_processor prevent null add/append to source document #35106
Conversation
* support for ignore_missing, such that if the field does not exist in source document the processor will be skipped * fix bug such that if the location to expand to already exists as nested objects, don't append a null value.
Pinging @elastic/es-core-infra |
After a some discussion with @talevy , I will remove the |
@talevy - changes made as discussed. The GH diff is kinda ugly, but it really a 1 line change. |
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.
left some questions, otherwise looks good!
@@ -143,4 +143,41 @@ public void testEscapeFields_path() throws Exception { | |||
assertThat(document.getFieldValue("field.foo.bar.baz", String.class), equalTo("value")); | |||
} | |||
|
|||
|
|||
public void testEscapeFields_doNotingIfFieldNotInSourceDoc() throws Exception { |
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.
s/doNoting/doNothing
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.
done.
//hasField returns false since it requires the expanded form, which is not expanded since we did not ask for it to be | ||
assertFalse(document.hasField("foo.bar")); | ||
//nothing has changed | ||
assertEquals(document.getSourceAndMetadata().get("foo.bar"), source.get("foo.bar")); |
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.
is this necessary given the next line?
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.
I guess, are any of the other assertions necessary given that we are checking that source has not changed at all in this case (and no metadata was added).
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.
actually, comparing to source is mis-leading since source is the object that is getting changed, so assertEquals(document.getSourceAndMetadata(), source);
is like asserting 1==1.
I removed the assertions against source and kept the specific assertions. Thanks for spotting this.
assertTrue(document.hasField("foo.bar")); | ||
//nothing changed | ||
assertEquals(document.getSourceAndMetadata().get("foo.bar"), source.get("foo.bar")); | ||
assertEquals(document.getSourceAndMetadata(), source); |
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.
same question as above, is this not a deep enough equals?
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.
removed all misleading assertions against source
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.
LGTM. thanks!
…ment (#35106) * don't allow null values to be added or appended to the source document if the field does not exist.
6.6.0 backport : 1e02754 |
if the field does not exist in the source document.
if the field does not exist in the source document.
I noticed some peculiar behavior w/r/t the dot expander processor adding in
null
values when either 1) the field declared is missing from the source document 2) the source document already contains the nested objects. For example:Results in:
With this change:
EDIT : updated text to match latest commit (examples did not need to change)