-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add support for context aware autocompletion #171
Conversation
Backend code coverage report for PR #171 |
Frontend code coverage report for PR #171
|
.type( | ||
`{selectall} | ||
SELECT $__parseTime(eventtime, 'yyyy-MM-dd''T''HH:mm:ss''Z'), sum(cast(json_extract_scalar(additionaleventdata, '$.bytesTransferredOut') as real)) AS bytes | ||
FROM $__table WHERE additionaleventdata IS NOT NULL AND json_extract_scalar(additionaleventdata, '$.bytesTransferredOut') IS NOT NULL AND $__timeFilter(eventtime, 'yyyy-MM-dd''T''HH:mm:ss''Z') |
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.
Need to adjust formatting slightly here so that suggestions are not accepted when hitting enter to get a newline. :)
The editor was different because the format selector does not make sense in the variable editor, it should always be "Table". It's a, maybe minor, UX 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.
👍 The autocompletion works flawlessly, nice!
When trying this I noticed a bug though (but it seems that it's not related to this PR). It seems that setting the catalog, database or column to the "default" is not working anymore. This is the curated dashboard:
And this is a fresh new panel:
Feel free to ignore that comment and address it in a different issue if it's not related!
package.json
Outdated
@@ -18,6 +18,7 @@ | |||
"author": "Grafana Labs", | |||
"license": "Apache-2.0", | |||
"devDependencies": { | |||
"@grafana/experimental": "^0.0.2-canary.38", |
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.
what happens if Athena is run with a lower version of Grafana? (that does not include the latest experimental package)
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.
yeah good shout, better make this a dependency. I wonder what would happen though if grafana is running a version of the experimental package that is lower than the plugin specifies..?
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 belive it gets ignored, no matter if it's a dependency or a devdep (there is no reference to the deps in the dist
folder, when you build a plugin).
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.
Should be fine since experimental package is not specified as an external dep in core grafana
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.
oh, I didn't know it works that way, interesting!
sorry! it may be that I had old deps installed, after reinstalling everything I don't find that issue |
// Verify editor suggestions | ||
e2eSelectors.QueryEditor.CodeEditor.container().click({ force: true }).type(`{selectall}$__table`); | ||
e2eSelectors.QueryEditor.CodeEditor.container().contains('(Macro) cloudtrail_logs'); | ||
// The follwing section will verify that autocompletion in behaving as expected. |
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 follwing section will verify that autocompletion in behaving as expected. | |
// The following section will verify that autocompletion in behaving as expected. |
description: 'Will return the current ending time of the time range. Use second argument to specify time format.', | ||
}, | ||
{ | ||
id: '$__unixEpochFilter()', |
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.
A reminder about the macro corrections for this pr
return ( | ||
<SQLCodeEditor | ||
query={query.rawSQL} | ||
onBlur={() => onRunQuery()} |
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.
Is there a reason that this can't just be onBlur={onRunQuery}
?
This PR switches from using the CodeEditor that was used in the query editor, variable editor and annotation editor with the SQL CodeEditor from grafana/experimental. This adds autocompletion including suggestions for macros, functions, keywords, logical operators, comparison operators etc. Like before, athena uses standard SQL so no specific language components are being passed to the SQL CodeEditor. However, a custom completion item provider is used so that the plugin can resolve tables and columns used by the autocompletion engine.
Please note that the variable editor is now rendering the full QueryEditor, including the left form group with resource selector. This should be fine I think. Please add feedback here if any.
Fixes #111