OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

[MQL] support enhancing language selector

Open kavilla opened this issue 1 year ago • 9 comments

Description

Enable with data.enhancements.enabled: true

Allows for enhancing the data plugin UI service and search service.

Remaining work

  • Address issue with time range being invalid if previous state successfully queried and set it with a time range format that is invalid for the new query language
    • For example, DQL with quick time range (4 weeks to now), get results. Switch to PPL, even though PPL has a default time range enhancement. The props date range saved in the app state takes priority and sets the time range to quick range causing an error. I can still modify the time range and get a successful query but it will first fail until the user updates it to a non quick time range.
  • Add tests
  • Disable for plugins that do not support the functionality
    • By default index patterns are created with a unique ID. However, it can be enabled to create an index pattern with a custom ID that matches the name of the index pattern (which in turn maps to indices).
    • For seamless integration, the temp data frame would need to check if the index pattern that maps to the data frame name. And get it's id.
    • This means that dashboards with visualizations that were created with an index pattern unique ID still require the existing index pattern to exist in memory.

Issues Resolved

closes #6639 closes #6311

partially resolves: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5504

Screenshot

Screenshot 2024-04-18 at 4 26 44 PM(1)

Screenshot 2024-04-25 at 3 25 24 AM

Screenshot 2024-04-25 at 3 26 13 AM

Current full suite of configurations that a plugin can pass to the Data Plugin UI extension points:

export interface QueryEnhancement {
  // TODO: default have supported all data_sources?
  // or should data connect have a record of query enhancements that are supported
  language: string;
  search: SearchInterceptor;
  // Leave blank to support all data sources
  // supportedDataSourceTypes?: Record<string, GenericDataSource>;
  searchBar?: {
   // TODO: replacing the element completely
    showQueryInput?: boolean;
    showFilterBar?: boolean;
    showDatePicker?: boolean;
    showAutoRefreshOnly?: boolean;
    queryStringInput?: {
      // will replace '<data_source>' with the data source name
      initialValue?: string;
    };
    dateRange?: {
      initialFrom?: string;
      initialTo?: string;
    };
  };
  fields?: {
    // forces for features native to OSD but no integration for query language
    filterable?: boolean;
    visualizable?: boolean;
  };
  showDocLinks?: boolean;
}

Testing the changes

  • Pull down this branch & https://github.com/kavilla/qlDashboards
  • Start up OpenSearch with required plugins yarn opensearch snapshot --sql
  • Start up OSD with yarn start --data.enhancements.enabled: true

Changelog

  • feat: Support language selector from the data 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

kavilla avatar Apr 23 '24 11:04 kavilla

ℹ️ Manual Changeset Creation Reminder

Please ensure manual commit for changeset file 6613.yml under folder changelogs/fragments to complete this PR.

If you want to use the available OpenSearch Changeset Bot App to avoid manual creation of changeset file you can install it in your forked repository following this link.

For more information about formatting of changeset files, please visit OpenSearch Auto Changeset and Release Notes Tool.

github-actions[bot] avatar Apr 23 '24 11:04 github-actions[bot]

Codecov Report

Attention: Patch coverage is 26.66667% with 308 lines in your changes are missing coverage. Please review.

Project coverage is 67.47%. Comparing base (bce6827) to head (4535590).

Files Patch % Lines
src/plugins/data/common/data_frames/utils.ts 9.33% 136 Missing :warning:
src/plugins/data/public/ui/settings/settings.ts 0.00% 24 Missing :warning:
...public/ui/query_string_input/query_bar_top_row.tsx 16.00% 17 Missing and 4 partials :warning:
.../data/common/search/search_source/search_source.ts 15.78% 14 Missing and 2 partials :warning:
...public/ui/query_string_input/language_switcher.tsx 56.66% 8 Missing and 5 partials :warning:
src/plugins/data/public/search/search_service.ts 20.00% 12 Missing :warning:
src/plugins/data/server/search/search_service.ts 7.69% 12 Missing :warning:
src/plugins/data/public/ui/ui_service.ts 0.00% 11 Missing :warning:
...on/index_patterns/index_patterns/index_patterns.ts 38.46% 6 Missing and 2 partials :warning:
...on/search/search_source/fetch/get_search_params.ts 33.33% 6 Missing and 2 partials :warning:
... and 16 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6613      +/-   ##
==========================================
- Coverage   67.73%   67.47%   -0.27%     
==========================================
  Files        3417     3428      +11     
  Lines       66956    67336     +380     
  Branches    10895    10994      +99     
==========================================
+ Hits        45352    45432      +80     
- Misses      18958    19234     +276     
- Partials     2646     2670      +24     
Flag Coverage Δ
Linux_1 33.04% <12.73%> (-0.12%) :arrow_down:
Linux_2 55.13% <8.36%> (-0.45%) :arrow_down:
Linux_3 45.00% <26.87%> (-0.25%) :arrow_down:
Linux_4 34.72% <11.74%> (-0.16%) :arrow_down:
Windows_1 33.06% <12.73%> (-0.12%) :arrow_down:
Windows_2 55.10% <8.36%> (-0.45%) :arrow_down:
Windows_3 45.00% <26.87%> (-0.27%) :arrow_down:
Windows_4 34.72% <11.74%> (-0.16%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 23 '24 11:04 codecov[bot]

❌ Invalid Prefix For Manual Changeset Creation

Invalid description prefix. Found "feat". Only "skip" entry option is permitted for manual commit of changeset files.

If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description.

github-actions[bot] avatar Apr 23 '24 20:04 github-actions[bot]

Still observing issues related to the default date range. Besides that part i believe this is in a ready state to review.

kavilla avatar Apr 25 '24 08:04 kavilla

❌ Invalid Prefix For Manual Changeset Creation

Invalid description prefix. Found "feat". Only "skip" entry option is permitted for manual commit of changeset files.

If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description.

github-actions[bot] avatar Apr 25 '24 10:04 github-actions[bot]

❌ Invalid Prefix For Manual Changeset Creation

Invalid description prefix. Found "feat". Only "skip" entry option is permitted for manual commit of changeset files.

If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description.

github-actions[bot] avatar Apr 25 '24 10:04 github-actions[bot]

❌ Invalid Prefix For Manual Changeset Creation

Invalid description prefix. Found "feat". Only "skip" entry option is permitted for manual commit of changeset files.

If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description.

github-actions[bot] avatar Apr 25 '24 10:04 github-actions[bot]

❌ Invalid Prefix For Manual Changeset Creation

Invalid description prefix. Found "feat". Only "skip" entry option is permitted for manual commit of changeset files.

If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description.

github-actions[bot] avatar Apr 25 '24 10:04 github-actions[bot]

@AMoo-Miki mind taking a peek when you have the time. Can walk through it too.

kavilla avatar Apr 27 '24 00:04 kavilla

Link failure unrelated. Will open a subsequent PR of fast follows to feedback to this PR since this PR disables this feature by default.

kavilla avatar May 09 '24 21:05 kavilla

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

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-6613-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7d9b3cd2e0e44b3b502c910f9288045219d78014
# Push it to GitHub
git push --set-upstream origin backport/backport-6613-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 base branch is 2.x and the compare/head branch is backport/backport-6613-to-2.x.

The backport to 2.14 failed:

The process '/usr/bin/git' failed with exit code 1

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.14 2.14
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.14
# Create a new branch
git switch --create backport/backport-6613-to-2.14
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7d9b3cd2e0e44b3b502c910f9288045219d78014
# Push it to GitHub
git push --set-upstream origin backport/backport-6613-to-2.14
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.14

Then, create a pull request where the base branch is 2.14 and the compare/head branch is backport/backport-6613-to-2.14.