-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix StoredFieldsSpec#merge(...) issue #138306
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?
Conversation
If StoredFieldsSpec requires source and has no sourcePaths, then it requires the whole source. For example, in case of `SourceFieldBlockLoader`. When merging StoredFieldsSpec then omit the sourcePaths of the other StoredFieldsSpec. Closes elastic#138188
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
| mergedSourcePaths.addAll(other.sourcePaths); | ||
| } else if (this.sourcePaths.isEmpty() == false) { | ||
| mergedSourcePaths = this.sourcePaths; | ||
| if (other.requiresSource) { |
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.
Ah! So our intuition was right - every time we apply the filter, we are stripping down the rest of the source. The fix is to always keep the source if it's been asked for
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.
As a side note, there seems to be quite a bit of boiler plate in this method, with some repeated outcomes. Do we want to shove them into separate tiny inlinable functions?
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.
Let me see if that actually makes to code cleaner.
| index: my-index2 | ||
| body: | ||
| mappings: | ||
| dynamic: false |
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 important? The dynamic I mean
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.
For the query being tested here, yes. Otherwise the test wouldn't fail.
The FROM my-index2 METADATA _source | LIMIT 10 requests all mapped fields, but because baz isn't mapped without the fix to StoredFieldSpec, we would filter it out. If the baz field was mapped, the stored field spec of the other column would include it in the final stored field spec.
| - do: | ||
| esql.query: | ||
| body: | ||
| query: 'FROM my-index2 METADATA _source | LIMIT 10' |
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.
Not to be annoying, but are we testing here with what we actually want to be testing?
Here we seem to have an index with a single text field, so even if we had not fixed the bug, I think this still would've worked, right - we would've stripped the source of everything but the field, which doesn't actually change the _source.
Feels like we need the mapping with at least one another field, and the query that reads the entire source and the text field. We should be testing that the filtered out field is still returned in source
This thing - #138188 - has the correctly shaped example I think.
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.
Here we seem to have an index with a single text field, so even if we had not fixed the bug, I think this still would've worked, right - we would've stripped the source of everything but the field, which doesn't actually change the _source.
Without the fix to StoredFieldSpec this test fails.
I can add a @timestamp field, but that doesn't change the outcome of the test.
|
Also on the |
| spec = spec.merge( | ||
| new StoredFieldsSpec( | ||
| true, | ||
| false, |
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.
So this may be silly question, but it seems like we very much changed the meaning of this test, right? The way I read this, we changed requiresSource to false, which - in some sense - triggers the "pre-bug" behavior. This makes sense.
Should we add a mirror test with this flag set to true?
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.
The test just walks through a few scenarios and I just appended the scenario that triggered the bug. I can add a dedicated unit test for the bug here.
If StoredFieldsSpec requires source and has no sourcePaths, then it requires the whole source. For example, in case of
SourceFieldBlockLoader. When merging StoredFieldsSpec then omit the sourcePaths of the other StoredFieldsSpec.Closes #138188
(a non released issue)