-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Lens] Enables text-based languages (SQL) #140469
Conversation
@@ -315,7 +315,7 @@ export const getUiSettings: (docLinks: DocLinksServiceSetup) => Record<string, U | |||
value: false, | |||
description: i18n.translate('discover.advancedSettings.enableSQLDescription', { | |||
defaultMessage: | |||
'{technicalPreviewLabel} This tech preview feature is highly experimental--do not rely on this for production saved searches or dashboards. This setting enables SQL as a text-based query language in Discover. If you have feedback on this experience please reach out to us on {link}', | |||
'{technicalPreviewLabel} This tech preview feature is highly experimental--do not rely on this for production saved searches, visualizations or dashboards. This setting enables SQL as a text-based query language in Discover and Lens. If you have feedback on this experience please reach out to us on {link}', |
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.
ℹ️ We are using the same switch with discover. I have slightly changed the text to include Lens. The setting is still on the Discover section.
@@ -262,7 +271,7 @@ export function ChangeDataView({ | |||
setIsTextBasedLangSelected(false); | |||
// clean up the Text based language query | |||
onTextLangQuerySubmit?.({ | |||
language: 'kql', | |||
language: 'kuery', |
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.
ℹ️ This is called on cleanup (i.e. when navigating from the text based languages mode to the dataviewMode. I was wrongly setting the language to kql while it is kuery
return ( | ||
<> | ||
<Easteregg query={externalContext?.query} /> | ||
{Object.keys(props.datasourceMap).length > 1 && ( |
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.
ℹ️ This was adding a popover for changing datasources (in case of more than one). In this PR we are introducing a new datasource so this begun to be displayed but we don't want it. The datasource change is done by the dataview picker.
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
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.
Bundle bump LGTM
@@ -158,7 +159,7 @@ const toExpression = ( | |||
showLabels: [!attributes?.mode || attributes?.mode === 'full'], | |||
colorMode: !canColor ? [ColorMode.None] : [state?.colorMode || ColorMode.None], | |||
autoScale: [true], | |||
colorFullBackground: [true], | |||
colorFullBackground: [!isTextBasedLanguage], |
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.
If this is because of the possibility of multiple metrics being rendered, then I think it's fine to just ignore it.
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.
@flash1293 I did this, because when this is set to true I get this error
Any suggestions here?
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.
IMHO that's alright for now (especially as it's only the legacy vis)
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.
Done 61b1af1
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.
On dashboards it doesn't reload when changing the time range (it does reload when changing filters though)
@flash1293 timeRange error fixed! Thanx for the great help! I have also removed the cleaning up of the layers on easy query update. You can see how it works now here: |
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.
app services code LGTM
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.
DataDiscovery.team owned code LGTM, just a function and a Advanced setting was renamed. SQL in Discover works as expected
const layer = props.state.layers[props.layerId]; | ||
const selectedField = layer?.allColumns?.find( | ||
(column) => column.columnId === props.columnId | ||
)!; |
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 selected field might be not available, we should handle this case by rendering a "FIELD MISSING" label or something like that.
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.
Done 309b68c
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.
This works pretty well now - just found one issue
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.
Tested again and everything works fine. Thanks for the change with not dropping the config on query change, it works like a charm!
Thanx for your comments Joe! |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
* [Lens] Enable text-based languages-sql * Display data * Chart switcher and further fixes * Drag and drop fixes * Small fix * Multiple improvements * Errors implementation and save and exit * Some cleanup * Fix types failures * Revert change * Fix underlying data error * Fix jest test * Fixes app test * Rename datasource to textBased * display the dataview picker component but disabled * Fix functional test * Refactoring * Populate the dataview to theembeddable * Load sync * sync load of the new dtsource * Fix * Fix bug when the dtaview is not found * Refactoring * Add some unit tests * Add some unit tests * Add more unit tests * Add a functional test * Add all files * Update lens limit * Fixes bug * Bump lens size * Fix flakiness * Further fixes * Fix check * More fixes * Fix test * Wait for query to run * More changes * Fix * Fix the function input to fetch from variable * Remove the colorFullBackground check * Fix dashboard bug when timeRange changes * Remove the clear on query update, show column error instead * Render a field missing label in case the label is not defined * Fix Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
Summary
Closes #137811
Enables text based query languages in Lens.
This is the initial PR so many features are not included. It's primary goal is to set up the architecture of the text based languages in Lens. Things to have in mind:
How to test
The feature is hidden under an advanced setting. To enable it go to advanced settings and switch on the "Enable SQL" setting. If you navigate to Lens and open the dataview picker you will see a new entry
Flaky runners
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1303 25 times
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1304 100 times
Checklist