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

Raw SQL Code Editor #364

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

Raw SQL Code Editor #364

wants to merge 5 commits into from

Conversation

jrgns
Copy link

@jrgns jrgns commented Oct 22, 2024

This PR adds the ability to query IOT Sitewise data using the query language

This was previously attempted in #268 and allows users to use SQL to query data instead of the query builder. Using SQL allows for richer, customized queries that can combine data from multiple sources to be combined and presented in Grafana panels.

The UI when editing a panel. This shows a line graph of the returned data:

image

Notice the buttons in the header of the query, next to Run queries where the user can switch between the Builder (orinal) and Code (new).

The screenshot below shows the same information, but shows the raw data instead of the line graph:

image

And lastly the query and returned data in the Explorer view:

image

Delivery items

  • Simple query editor
  • Handler for SQL queries

See jadeit#1 for

  • Macro replacements ($__from, $__to, etc)
  • Code completion
  • Frontend Tests
  • Backend Tests

Sorry, something went wrong.

@jrgns jrgns requested a review from a team as a code owner October 22, 2024 21:29
@jrgns jrgns requested review from kevinwcyu and njvrzm and removed request for a team October 22, 2024 21:29
@CLAassistant
Copy link

CLAassistant commented Oct 22, 2024

CLA assistant check
All committers have signed the CLA.

pkg/models/query.go Outdated Show resolved Hide resolved
{editorMode === QueryEditorMode.Builder && (
<VisualQueryBuilder
datasource={props.datasource}
query={query}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Swapping between modes will keep the query as a SqlQuery. Can consider storing the last selected query in the Builder mode to update the query when swapping between Code and Builder.

@hwandersman
Copy link
Collaborator

High level comments:

  1. My understanding is that the ExecuteQuery API is used to fetch SiteWise assets and asset metadata. This would be used as another option instead of the dropdowns / asset browser capability in the QueryEditor. Right now you have a toggle between the builder and code mode, but I think this should be contained within the builder mode as a way to find assets/properties to build a query to fetch data. This can be a feature of the asset browser so instead of the "Hierarchy" or "By Model" tabs there is a 3rd tab which is "By Query" or something like that.
  2. Builder vs Code mode - Code mode as a standalone query misses all of the query options we have for our SiteWise queries (caching, L4E, etc.). Another reason the ExecuteQuery should be a sub-feature of asset selection in the asset browser.

@jrgns jrgns changed the title Sql query type Raw SQL Code Editor Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Next
Development

Successfully merging this pull request may close these issues.

None yet

3 participants