Skip to content

Commit 0f319a6

Browse files
committed
replace sqlds.Query with sqlutil.Query
1 parent e1d7a10 commit 0f319a6

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

pkg/bigquery/datasource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func (s *BigQueryDatasource) Projects(options ProjectsArgs) ([]*Project, error)
307307
type ValidateQueryArgs struct {
308308
Project string `json:"project"`
309309
Location string `json:"location"`
310-
Query sqlds.Query `json:"query"`
310+
Query sqlutil.Query `json:"query"`
311311
TimeRange backend.TimeRange `json:"range"`
312312
}
313313

pkg/bigquery/macros.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ import (
66
"strings"
77

88
"github.com/grafana/grafana-plugin-sdk-go/backend/gtime"
9+
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
910
"github.com/grafana/sqlds/v3"
1011
)
1112

12-
func macroColumn(query *sqlds.Query, args []string) (string, error) {
13+
func macroColumn(query *sqlutil.Query, args []string) (string, error) {
1314
return "", errors.New("$__column macro is not supported")
1415
}
1516

16-
func macroTable(query *sqlds.Query, args []string) (string, error) {
17+
func macroTable(query *sqlutil.Query, args []string) (string, error) {
1718
return "", errors.New("$__table macro is not supported")
1819
}
1920

20-
func macroTimeGroup(query *sqlds.Query, args []string) (string, error) {
21+
func macroTimeGroup(query *sqlutil.Query, args []string) (string, error) {
2122
if len(args) < 2 {
2223
return "", fmt.Errorf("%w: expected 2 arguments, received %d", errors.New("macro $__timeGroup needs time column and interval"), len(args))
2324
}

pkg/bigquery/macros_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,55 @@ package bigquery
33
import (
44
"testing"
55

6-
"github.com/grafana/sqlds/v3"
6+
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
77
"github.com/pkg/errors"
88
)
99

1010
func Test_macros(t *testing.T) {
1111
tests := []struct {
1212
description string
1313
macro string
14-
query *sqlds.Query
14+
query *sqlutil.Query
1515
args []string
1616
expected string
1717
expectedErr error
1818
}{
1919
{
2020
"time groups 1w",
2121
"timeGroup",
22-
&sqlds.Query{},
22+
&sqlutil.Query{},
2323
[]string{"created_at", "1w"},
2424
"TIMESTAMP_MILLIS(DIV(UNIX_MILLIS(created_at), 604800000) * 604800000)",
2525
nil,
2626
},
2727
{
2828
"time groups 1d",
2929
"timeGroup",
30-
&sqlds.Query{},
30+
&sqlutil.Query{},
3131
[]string{"created_at", "1d"},
3232
"TIMESTAMP_MILLIS(DIV(UNIX_MILLIS(created_at), 86400000) * 86400000)",
3333
nil,
3434
},
3535
{
3636
"time groups 1M",
3737
"timeGroup",
38-
&sqlds.Query{},
38+
&sqlutil.Query{},
3939
[]string{"created_at", "1M"},
4040
"TIMESTAMP((PARSE_DATE(\"%Y-%m-%d\",CONCAT( CAST((EXTRACT(YEAR FROM created_at)) AS STRING),'-',CAST((EXTRACT(MONTH FROM created_at)) AS STRING),'-','01'))))",
4141
nil,
4242
},
4343
{
4444
"time groups '1M'",
4545
"timeGroup",
46-
&sqlds.Query{},
46+
&sqlutil.Query{},
4747
[]string{"created_at", "'1M'"},
4848
"TIMESTAMP((PARSE_DATE(\"%Y-%m-%d\",CONCAT( CAST((EXTRACT(YEAR FROM created_at)) AS STRING),'-',CAST((EXTRACT(MONTH FROM created_at)) AS STRING),'-','01'))))",
4949
nil,
5050
},
5151
{
5252
"time groups \"1M\"",
5353
"timeGroup",
54-
&sqlds.Query{},
54+
&sqlutil.Query{},
5555
[]string{"created_at", "\"1M\""},
5656
"TIMESTAMP((PARSE_DATE(\"%Y-%m-%d\",CONCAT( CAST((EXTRACT(YEAR FROM created_at)) AS STRING),'-',CAST((EXTRACT(MONTH FROM created_at)) AS STRING),'-','01'))))",
5757
nil,

0 commit comments

Comments
 (0)