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

Moving SQL and PPL Provider Registration to Query Enhancements Plugin #9591

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

Conversation

ananzh
Copy link
Member

@ananzh ananzh commented Mar 22, 2025

Description

Autocomplete Service

  • Located in src/plugins/data/public/autocomplete/autocomplete_service.ts
  • Provides methods to register query suggestion providers for different languages
  • Exposes addQuerySuggestionProvider in its setup contract
  • Remains in the data plugin as a central registry for all autocomplete providers

Language Registration

  • The data plugin now only registers the DQL language provider in its setup method:
// In src/plugins/data/public/plugin.ts
autoComplete.addQuerySuggestionProvider('kuery', getDQLSuggestions);
  • The query_enhancements plugin registers SQL and PPL providers in its setup method:
// In src/plugins/query_enhancements/public/plugin.tsx
data.autocomplete.addQuerySuggestionProvider('SQL', getSQLSuggestions);
data.autocomplete.addQuerySuggestionProvider('PPL', getPPLSuggestions);

Language Implementations/Providers

  • DQL suggestions: src/plugins/data/public/antlr/dql/code_completion.ts (unchanged)
  • SQL suggestions:
    • Original implementation in src/plugins/data/public/antlr/opensearch_sql/code_completion.ts (now deprecated)
    • New implementation in src/plugins/query_enhancements/public/autocomplete/sql_suggestions.ts
  • PPL suggestions:
    • Original implementation in src/plugins/data/public/antlr/opensearch_ppl/code_completion.ts (now deprecated)
    • New implementation in src/plugins/query_enhancements/public/autocomplete/ppl_suggestions.ts

Shared Utilities and Components

  • The data plugin exports shared utilities and ANTLR-related components through its public API:
// In src/plugins/data/public/index.ts
export {
  fetchColumnValues,
  formatFieldsToSuggestions,
  formatValuesToSuggestions,
  parseQuery,
} from './antlr/shared/utils';
export { SuggestionItemDetailsTags } from './antlr/shared/constants';
export { SQL_SUGGESTION_IMPORTANCE, SQL_SYMBOLS } from './antlr/opensearch_sql/constants';
export { openSearchSqlAutocompleteData } from './antlr/opensearch_sql/opensearch_sql_autocomplete';
export { getOpenSearchSqlAutoCompleteSuggestions } from './antlr/opensearch_sql/code_completion';
export { PPL_AGGREGATE_FUNCTIONS, PPL_SUGGESTION_IMPORTANCE } from './antlr/opensearch_ppl/constants';
export { openSearchPplAutocompleteData } from './antlr/opensearch_ppl/opensearch_ppl_autocomplete';
export { getOpenSearchPplAutoCompleteSuggestions } from './antlr/opensearch_ppl/code_completion';

Query Enhancements Plugin

  • Registers language configurations for SQL and PPL in src/plugins/query_enhancements/public/plugin.tsx
  • Now also registers autocomplete providers for SQL and PPL
  • Implements sophisticated SQL and PPL suggestion providers that use the shared utilities and ANTLR-related components from the data plugin

Current Implementation of Syntax/Error Highlighting

  • There doesn't appear to be a dedicated service for syntax highlighting or error highlighting
  • Monaco editor likely handles basic syntax highlighting based on language configuration
  • Error highlighting might be handled by Monaco's validation capabilities, but there are no explicit error highlighting providers

Issues Resolved

#9584

Screenshot

refactor.mp4

Changelog

  • refactor: Moving SQL and PPL Provider Registration to Query Enhancements Plugin

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

@d-buckner
Copy link
Member

Nice! I ran into some trouble defining the PromQL without having access to query_enhancements, this definitely helps out. I'll make sure that the promQL suggestions get moved to query_enhancements as well before we send PRs for main.

Copy link

codecov bot commented Mar 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.11%. Comparing base (6cf85af) to head (e3bf659).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9591      +/-   ##
==========================================
- Coverage   61.81%   61.11%   -0.70%     
==========================================
  Files        3825     3825              
  Lines       92058    91993      -65     
  Branches    14602    14579      -23     
==========================================
- Hits        56902    56221     -681     
- Misses      31482    32174     +692     
+ Partials     3674     3598      -76     
Flag Coverage Δ
Linux_1 28.97% <0.00%> (+0.02%) ⬆️
Linux_2 56.38% <ø> (ø)
Linux_3 ?
Linux_4 28.87% <0.00%> (+0.03%) ⬆️
Windows_1 28.99% <0.00%> (+0.02%) ⬆️
Windows_2 56.33% <ø> (ø)
Windows_3 38.30% <100.00%> (-1.13%) ⬇️
Windows_4 28.87% <0.00%> (+0.03%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants