Skip to content
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] PPL & SQL Value Suggestion #8275

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

paulstn
Copy link
Contributor

@paulstn paulstn commented Sep 20, 2024

Description

Only done for opensearch SQL + PPL

SQL:

Screen.Recording.2024-10-09.at.11.51.51.AM.mov

PPL:

Screen.Recording.2024-10-09.at.11.42.04.AM.mov

src/plugins/data/public/antlr/*

For PPL & SQL, uses the SQL query

SELECT <column> FROM <table> GROUP BY <column> ORDER BY COUNT(<column>) DESC LIMIT <limit>

to find the most popular column values to display within autocomplete whenever a value should be suggested.

src/plugins/data/server/ui_settings.ts

There were two UI settings added.
query:enhancements:suggestValues is a boolean that determines if value suggestion will be used
query:enhancements:suggestValuesLimit is a number that specifies how many values should be queried, defaulting to 200

src/plugins/data/public/autocomplete/autocomplete_service.ts

The ability to add a value suggestion provided was included in this pr, but isn't in use so far. Creating a value suggestion provider that would make the api call (with all of the same parameters that exist right now) could be done but would require a lot of complexity for what is essentially done in 10 lines today.

This PR also contains various fixes and quality of life updates within SQL & PPL suggestions.

Issues Resolved

Screenshot

Testing the changes

Field level security testing:

Screen.Recording.2024-10-21.at.2.22.46.PM.mov

Field level masking testing:

Screen.Recording.2024-10-21.at.2.09.44.PM.mov

Changelog

  • feat: Autocomplete Value Suggestion

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Copy link
Contributor

❌ Empty Changelog Section

The 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.

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 12.28070% with 50 lines in your changes missing coverage. Please review.

Project coverage is 60.82%. Comparing base (7da5443) to head (3381377).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...ntlr/opensearch_ppl/opensearch_ppl_autocomplete.ts 0.00% 12 Missing ⚠️
...s/data/public/autocomplete/autocomplete_service.ts 0.00% 12 Missing ⚠️
...ata/public/antlr/opensearch_sql/code_completion.ts 0.00% 11 Missing ⚠️
...ata/public/antlr/opensearch_ppl/code_completion.ts 0.00% 10 Missing ⚠️
src/plugins/data/public/antlr/shared/utils.ts 55.55% 4 Missing ⚠️
...ntlr/opensearch_sql/opensearch_sql_autocomplete.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8275      +/-   ##
==========================================
- Coverage   60.85%   60.82%   -0.04%     
==========================================
  Files        3793     3793              
  Lines       90368    90373       +5     
  Branches    14181    14184       +3     
==========================================
- Hits        54997    54970      -27     
- Misses      31893    31928      +35     
+ Partials     3478     3475       -3     
Flag Coverage Δ
Linux_1 ?
Linux_2 56.39% <ø> (ø)
Linux_3 37.63% <12.28%> (-0.05%) ⬇️
Linux_4 29.82% <7.01%> (-0.01%) ⬇️
Windows_1 29.11% <7.01%> (-0.01%) ⬇️
Windows_2 56.34% <ø> (ø)
Windows_3 37.63% <12.28%> (-0.06%) ⬇️
Windows_4 29.82% <7.01%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Signed-off-by: Paul Sebastian <paulstn@amazon.com>
src/plugins/data/public/ui/query_editor/query_editor.tsx Outdated Show resolved Hide resolved
src/plugins/data/public/antlr/shared/utils.ts Outdated Show resolved Hide resolved
src/plugins/data/public/antlr/shared/utils.ts Show resolved Hide resolved
src/plugins/data/server/ui_settings.ts Outdated Show resolved Hide resolved
paulstn and others added 4 commits October 9, 2024 10:51
Signed-off-by: Paul Sebastian <paulstn@dev-dsk-paulstn-2b-a4d3f011.us-west-2.amazon.com>
Signed-off-by: Paul Sebastian <paulstn@dev-dsk-paulstn-2b-a4d3f011.us-west-2.amazon.com>
Signed-off-by: Paul Sebastian <paulstn@dev-dsk-paulstn-2b-a4d3f011.us-west-2.amazon.com>
Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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
Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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.

Signed-off-by: Paul Sebastian <paulstn@dev-dsk-paulstn-2b-a4d3f011.us-west-2.amazon.com>
Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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.

5 similar comments
Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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.

Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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.

Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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.

Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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.

Copy link
Contributor

github-actions bot commented Oct 9, 2024

❌ Empty Changelog Section

The 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.

Signed-off-by: Paul Sebastian <paulstn@dev-dsk-paulstn-2b-a4d3f011.us-west-2.amazon.com>
Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems it's simplifying some of the comparison grammars, any context on why they are needed?

@@ -291,7 +291,7 @@ expression

predicate
: expressionAtom # expressionAtomPredicate
| left = predicate comparisonOperator right = predicate # binaryComparisonPredicate
| left = predicate comparisonOperator right = constant # binaryComparisonPredicate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line, along with line 307/308, was changed so that values don't get suggested for the left side of a predicate, while the right side doesn't have field names suggested and only values suggested instead. Although having a constant on the left and a field on the right does get parsed, suggesting it is practically useless/ information overload. There would be too many suggestions and it doesn't make sense to show every single possibility.

src/plugins/data/public/antlr/shared/utils.ts Show resolved Hide resolved
export type ValueSuggestionsGetFn = (args: ValueSuggestionsGetFnArgs) => Promise<any[]>;
export type ValueSuggestionsGetFn = (
args: ValueSuggestionsGetFnArgs | ValueSuggestionsSQLGetFnArgs
) => Promise<any[]>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np. might be better to put args type and return type as generic, to allow extending and keeps autocomplete generic to what languages are used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I fully understand what making the args or the return type generic would accomplish. Since this file is meant to include the implementation for functions that would do the value completion, they require specific inputs that may not be related to the output.
To keep autocomplete generic to the languages used, should I just change the name of the function to move away from "SQL"?

@mengweieric
Copy link
Collaborator

Just summarize some of the concerns for this PR that I feel we need to address:

Grammar Changes:
Modifying the grammar directly is not considered an optimal approach, as it introduces risks of mismatches with removed or modified grammar rules. We should prioritize leveraging visitors, token streams, and logical code adjustments to achieve the intended behavior.

Test Coverage:
There is insufficient test coverage to ensure the modified grammar behaves consistently with previous expectations. Additional tests should be added to confirm the correctness of the changes if we want to go ahead with grammar changes.

Value Suggestions:
While value suggestions are not a typical feature for SQL/PPL languages, it is acceptable in this context. However, the current implementation still has gaps in providing a meaningful suggestion experience, such as suggesting masked values.

Unaddressed Comments:
Some comments have not been addressed yet. Please ensure that all feedback is reviewed and handled accordingly.

@kavilla kavilla added v2.19.0 and removed v2.18.0 labels Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants