generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 187
[Feature] Calcite PPL search result highlighting #5141
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
Open
RyanL1997
wants to merge
18
commits into
opensearch-project:main
Choose a base branch
from
RyanL1997:syntax-highlighting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ac13a8a
Calcite PPL search result highlighting
RyanL1997 3b59ea1
[review-ready] highligting with ppl api pass-through design
RyanL1997 5c1557b
Add tests
RyanL1997 40cee36
style cleanup
RyanL1997 fcf44a9
add another test case
RyanL1997 71faa1f
fix tests
RyanL1997 1b7d1a4
peng - _highlight hiden column
RyanL1997 0283f28
peng - add doc
RyanL1997 97a8418
peng - hiden col solution 2
RyanL1997 cc6101a
update doc
RyanL1997 583b870
update docs
RyanL1997 b95f333
enhance highlight IT
RyanL1997 ddd292b
fix tests
RyanL1997 12672d6
coderabbit - enhancement of tests
RyanL1997 063f7d0
fix doc tests
RyanL1997 798396c
peng - fix tests with more assertions
RyanL1997 5bda888
Generalize highlight plumbing to generic DSL merge mechanism
RyanL1997 b290e06
chen - fix doc
RyanL1997 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 97
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1792
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 50378
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1744
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 365
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1538
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 2319
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1328
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 3601
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 4271
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1952
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 7296
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1137
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 172
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 48
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 243
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 48
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 48
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 5426
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1710
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 253
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 7756
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1559
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 951
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 397
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 3138
Guard against duplicate
_highlightprojection when using SELECT with mixed explicit fields and wildcards.When highlight is enabled and a user queries with mixed explicit fields and AllFields (e.g.,
SELECT name, *), the code can add_highlighttwice to the projection:expandProjectFieldsincludes_highlightvia AllFields expansion (since_highlightis not in METADATAFIELD_TYPE_MAP)Calcite may rename duplicate columns (e.g.,
_highlight0,_highlight1), which breaks downstream extraction that uses exact name matching viatuple.get(HIGHLIGHT_FIELD). The suggested guard checking for existing RexInputRef matches prevents this duplication.🔧 Suggested guard
if (CalcitePlanContext.getHighlightConfig() != null) { int hlIndex = currentFields.indexOf(HIGHLIGHT_FIELD); - if (hlIndex >= 0) { - expandedFields.add(context.relBuilder.field(hlIndex)); + if (hlIndex >= 0) { + boolean alreadyProjected = + expandedFields.stream() + .anyMatch( + rex -> + (rex instanceof RexInputRef ref && ref.getIndex() == hlIndex) + || (rex instanceof RexCall call + && call.getKind() == SqlKind.AS + && call.getOperands().get(0) instanceof RexInputRef ref + && ref.getIndex() == hlIndex)); + if (!alreadyProjected) { + expandedFields.add(context.relBuilder.field(hlIndex)); + } } }📝 Committable suggestion
🤖 Prompt for AI Agents