-
Notifications
You must be signed in to change notification settings - Fork 935
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
[Auto Suggest] Fix Grammar Changes #9120
[Auto Suggest] Fix Grammar Changes #9120
Conversation
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9120 +/- ##
==========================================
+ Coverage 61.68% 61.70% +0.02%
==========================================
Files 3816 3816
Lines 91693 91821 +128
Branches 14516 14542 +26
==========================================
+ Hits 56557 56662 +105
+ Misses 31510 31505 -5
- Partials 3626 3654 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
e9fff9a
to
d91f591
Compare
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
1 similar comment
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
e2e3843
to
81454db
Compare
cc91a16
to
f310ed4
Compare
f310ed4
to
b12ce80
Compare
b12ce80
to
bcc4e5f
Compare
Signed-off-by: Paul Sebastian <[email protected]>
… work with any lang and any number of rules Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Paul Sebastian <[email protected]>
… a general nonspecific combine function Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Paul Sebastian <[email protected]>
25d0ef5
to
435e2ea
Compare
Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Paul Sebastian <[email protected]>
@@ -223,6 +223,11 @@ export function processVisitedRules( | |||
'.' + removePotentialBackticks(nextToken?.text ?? ''); | |||
continue; | |||
} | |||
if (validIDToken(token)) { | |||
token.text = removePotentialBackticks(token.text ?? ''); |
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.
will clicking a backtick removed suggestion add backtick back to the query? Also why is it called potential backtick?
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 formation of this list sigTokens
is only used by this preferred rule on RULE_predicate
to interpret the predicate as its formed. So everything interacting with backticks is just removing them so that if we want to use value completion on a field that's already in the query that happens to have backticks, it can match the field name to the index pattern's field.
This is needed because value completion has default behavior of NOT sending an aggregation query if it can't match the field name to the current index's field list.
This change simply allows for values to be suggested if there are backticks in the field within the current predicate.
Regarding your question on if it will readd the backtick, it doesn't affect the field already in the query because this pref. rule doesn't suggest things that extend beyond the current 'word', so it will only replace the current token.
It's called potential backtick because I'm running this method on every token that could be an ID or backticked-ID, so it's just some regex that looks to remove backticks at the front and back, and doesn't require any specific type of input that has backticks for sure.
context, | ||
}); | ||
|
||
// combine result and nextResult |
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.
nit. good to have comments to describe the intent and any potential edge cases as I feel that the for and switch statement handles various data types and use cases, but it might not be immediately clear why certain cases (e.g., boolean or undefined) are treated a specific way.
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'll add a big comment outlining the details on combining results
@@ -65,18 +65,10 @@ export const getSuggestions = async ({ | |||
...PPL_AGGREGATE_FUNCTIONS.map((af) => ({ | |||
text: `${af}()`, | |||
type: monaco.languages.CompletionItemKind.Function, | |||
insertText: af + '(${1:expr}) ', | |||
insertText: af + ' ', |
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.
why remove?
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.
there were asks to remove it, since not many people knew how to use snippets (tab + keep tabbing to get to the next cursor place). this is primarily fueled by the version of monaco we're using, where snippets are a little buggy and also don't have the full functionality that current monaco has.
we should reintroduce them when monaco is updated.
could you check if failing CIs relevant? |
Signed-off-by: Paul Sebastian <[email protected]>
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-9120-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d227bc59c56a0ac4e3ffd691b9a0df1635839a84
# Push it to GitHub
git push --set-upstream origin backport/backport-9120-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x Then, create a pull request where the |
* sql more field name tests Signed-off-by: Paul Sebastian <[email protected]> * undo search command change w/ updated logic, generalize rerun flag to work with any lang and any number of rules Signed-off-by: Paul Sebastian <[email protected]> * beginning of updating combined results properly Signed-off-by: Paul Sebastian <[email protected]> * Changeset file for PR opensearch-project#9120 created/updated * cleaner non-recursive system to go through rerunWithout rule list and a general nonspecific combine function Signed-off-by: Paul Sebastian <[email protected]> * revert qualified name grammar Signed-off-by: Paul Sebastian <[email protected]> * revert from and table source grammars Signed-off-by: Paul Sebastian <[email protected]> * fix ppl field name issue Signed-off-by: Paul Sebastian <[email protected]> * remove ppl agg func snippets and update ppl field name test Signed-off-by: Paul Sebastian <[email protected]> * leave a space for sql agg func Signed-off-by: Paul Sebastian <[email protected]> * ppl autocomplete more pref. rules test Signed-off-by: Paul Sebastian <[email protected]> * remove backticks from ppl field name to match for value completion Signed-off-by: Paul Sebastian <[email protected]> * add comment explaining result combination Signed-off-by: Paul Sebastian <[email protected]> --------- Signed-off-by: Paul Sebastian <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Signed-off-by: Ubuntu <[email protected]>
Description
Redos changes made to the grammar meant for fixing bugs. Fixes those same original bugs through other means.
Also rewrites the 'redo and combine' functionality to be more robust.
The old system
The old system was simply a flag that could be set by a preferred rule to run code completion once with all the rules, and then another time without any rules, to finally combine the results from both.
The new system
The new system requires any preferred rule to submit its name, and then goes through that cumulative list to remove only that rule from the code completion process, combining every possible result it gets. This new system allows for multiple preferred rules to be left out of the code completion process if it happens to block keyword candidates, and also for every other potentially necessary preferred rule to still be in effect while it does so.
Diagram: (change made was for the "Main Parsing Loop")
Removes grammar changes from:
https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8087/files#diff-3dc92487ddb63ebd741b8639f39b9440158a1f31317978cbd84af144daf3adc0
Each grammar change reverted / with its corresponding fix:
, handled through a pref. rule but some behavior is left as is.
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration