-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: add support for multiple metrics queries
- Loading branch information
1 parent
40a347c
commit e0db144
Showing
9 changed files
with
240 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
# Changelog | ||
|
||
## 0.0.5 (Unreleased) | ||
## 0.0.6 | ||
|
||
Initial release. | ||
- Adds support for multiple metrics queries (SQL Editor only) | ||
- Fixes bug where saved query was not displayed in query builder | ||
|
||
--- | ||
|
||
### 0.0.5 | ||
|
||
- Adds full text SQL query editor with macros |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package plugin | ||
|
||
import ( | ||
"database/sql" | ||
"errors" | ||
"fmt" | ||
"github.com/grafana/grafana-plugin-sdk-go/backend/log" | ||
"github.com/grafana/grafana-plugin-sdk-go/data" | ||
"time" | ||
) | ||
|
||
func initDataframeTypes(columnTypes []*sql.ColumnType, columnNames []string, frame *data.Frame) (*data.Frame, error) { | ||
for i := 0; i < len(columnTypes); i++ { | ||
|
||
cName := columnNames[i] | ||
switch cType := columnTypes[i].DatabaseTypeName(); cType { | ||
case "BIGINT": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []int64{}), | ||
) | ||
case "BOOLEAN": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []bool{}), | ||
) | ||
case "DATE": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []string{}), | ||
) | ||
case "DOUBLE": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []float64{}), | ||
) | ||
case "FLOAT": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []float64{}), | ||
) | ||
case "INT": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []int32{}), | ||
) | ||
case "SMALLINT": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []int16{}), | ||
) | ||
case "STRING": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []string{}), | ||
) | ||
case "TIMESTAMP": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []time.Time{}), | ||
) | ||
case "TINYINT": | ||
frame.Fields = append(frame.Fields, | ||
data.NewField(cName, nil, []int8{}), | ||
) | ||
default: | ||
err := errors.New(fmt.Sprintf("Unsuported Type %s for column %s", cType, cName)) | ||
log.DefaultLogger.Info("Unsuported Type", "err", err) | ||
return frame, err | ||
} | ||
|
||
} | ||
return frame, nil | ||
} |
Oops, something went wrong.