ESQL: Fix Attribute#withQualifier ignoring the new qualifier - #152921
Conversation
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
|
Hi @SEPURI-SAI-KRISHNA — this PR has been identified as stalled (open and without meaningful updates for 30+ days). Please update the PR or confirm its status when you can. It will be closed in two weeks if there is no further activity. Please reply, push an update, or close it yourself if it is no longer needed. — Analytics PR review management |
The qualifier parameter shadowed the field, so Objects.equals(qualifier, qualifier) compared the parameter to itself and the method always returned this, never applying the new qualifier. Compare against qualifier() like the sibling with* methods do, and add a regression test. Fixes elastic#152920
d32cf8b to
8c259a7
Compare
|
Friendly ping — this picked up the stalled label, but I don't think there are open questions on it; it looks like it just never got a reviewer assigned (there's no CODEOWNERS entry The bug is still present on main: Attribute#withQualifier compares Objects.equals(qualifier, qualifier), where the parameter shadows the field, so the guard is unconditionally true There are no callers on main today, so there's no user-visible impact — but it will silently no-op for the qualifier work in flight. @elastic/es-analytical-engine could someone take a look, and kick off CI when you get a chance? cc @bpintea |
|
buildkite test this |
|
@alex-spies, the proposed solution here is correct, but the fixed method is currently dead code. Will we needed it later for the qualifiers work? Otherwise we might want to instead remove it. |
|
Thanks for the review and for kicking off CI, @bpintea. One data point that may help the keep-vs-remove call: this method is a port of xpack.ql.expression.Attribute#withQualifier (x-pack/plugin/ql/.../Attribute.java:89), where the comparison is correct and the method has live callers — sql Analyzer:1086 and SubQueryAlias:47, eql OptionalResolvedAttribute:65, and ql FieldAttribute:134. So the shadowing looks like it was introduced when the class was forked into esql-core, rather than being an intentionally unused stub. Confirmed the only caller in ES|QL today is the test added here. Happy either way — if you'd prefer removal, I can swap this PR to delete the method instead; just say which and I'll push. |
alex-spies
left a comment
There was a problem hiding this comment.
@alex-spies, the proposed solution here is correct, but the fixed method is currently dead code. Will we needed it later for the qualifiers work? Otherwise we might want to instead remove it.
Removing and fixing are both fine by me. Qualifiers are still planned at some point, so fixing is fine IMHO.
Let's just get this in, as this LGTM.
But let's not backport this, it's not a user-facing bug at all. For the same reason, I'll go and strip the changelog, given that the changelog is for changes in features, behavior etc. that users can experience.
Not a user-facing bug, no changelog needed.
|
Thanks for the contribution @SEPURI-SAI-KRISHNA , and thanks for the review @bpintea ! |
|
Thank you @alex-spies and @bpintea |
Fixes #152920
Attribute.withQualifier(String qualifier)compared the method parameter toitself (
Objects.equals(qualifier, qualifier)— the parameter shadows thefield of the same name), which is always
true. As a result the methodunconditionally returned
thisand silently never applied the new qualifier.All sibling methods (
withName,withLocation,withDataType) compare theaccessor against the parameter; this change makes
withQualifierdo the same:There are no callers of
withQualifierinmainyet, so there is nouser-visible impact today — but qualifiers in attributes are under active
development (
esql_qualifiers_in_attributes), and the first caller would havesilently received the original, unqualified attribute back.
Also adds a regression test (
ReferenceAttributeTests#testWithQualifier)asserting that the new qualifier is applied and that passing an equal
qualifier still returns the same instance without cloning.
Verified locally with
:x-pack:plugin:esql:test --tests "...ReferenceAttributeTests"(9/9 passing) and
:x-pack:plugin:esql:spotlessJavaCheck.