Skip to content

Commit

Permalink
Merge pull request #15 from mullerpeter/bugfix/scoped-variables
Browse files Browse the repository at this point in the history
🐛 fix: use scoped variables in template replacment
  • Loading branch information
mullerpeter authored Feb 28, 2023
2 parents 7a2f5b0 + 3ed99e6 commit 159dfba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Changelog

## 1.1.2

- Use scoped Variables in template variable replacement

---

### 1.1.0

- Adds proper type reflection to support all databricks data types. (except type `BINARY` which is not supported)
---

### 1.0.0

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mullerpeter-databricks-datasource",
"private": true,
"version": "1.1.1",
"version": "1.1.2",
"description": "Databricks SQL Connector",
"scripts": {
"build": "grafana-toolkit plugin:build",
Expand Down
6 changes: 3 additions & 3 deletions src/datasource.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { DataSourceInstanceSettings } from '@grafana/data';
import { DataSourceInstanceSettings, ScopedVars } from '@grafana/data';
import { DataSourceWithBackend, getTemplateSrv } from '@grafana/runtime';
import { MyDataSourceOptions, MyQuery } from './types';

export class DataSource extends DataSourceWithBackend<MyQuery, MyDataSourceOptions> {
constructor(instanceSettings: DataSourceInstanceSettings<MyDataSourceOptions>) {
super(instanceSettings);
}
applyTemplateVariables(query: MyQuery) {
applyTemplateVariables(query: MyQuery, scopedVars: ScopedVars) {
const templateSrv = getTemplateSrv();
return {
...query,
rawSqlQuery: query.rawSqlQuery ? templateSrv.replace(query.rawSqlQuery) : ''
rawSqlQuery: query.rawSqlQuery ? templateSrv.replace(query.rawSqlQuery, scopedVars) : ''
};
}
}

0 comments on commit 159dfba

Please sign in to comment.