Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dune/dune.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ func (c *duneClient) QueryCancel(executionID string) error {

func (c *duneClient) QueryExecute(queryID int, queryParameters map[string]string) (*models.ExecuteResponse, error) {
executeURL := fmt.Sprintf(executeURLTemplate, c.env.Host, queryID)
jsonData, err := json.Marshal(queryParameters)
jsonData, err := json.Marshal(models.ExecuteRequest{
QueryParameters: queryParameters,
})
if err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions models/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
"strings"
)

type ExecuteRequest struct {
QueryParameters map[string]string `json:"query_parameters,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

map[string]any

should be any, I don't know of a better way of saying:
it is either string or a float64 or an integer, maybe @diegoximenes or @jmsgu know..

Copy link
Contributor

@diegoximenes diegoximenes Oct 28, 2022

Choose a reason for hiding this comment

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

For (int | string) this can be useful: https://pkg.go.dev/k8s.io/apimachinery/pkg/util/intstr#IntOrString.
I am not sure if with the generics support from go 1.18 something nice appeared related to this kind of issue, I haven't used generics on golang yet.
Regarding float, usually I discourage using it for types on API interfaces, unless it is really necessary, due to round trip issues.
Check a little about k8s APIs handling numbers with Quantity (https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity) by the way: kubernetes-sigs/controller-tools#245

Copy link
Member Author

Choose a reason for hiding this comment

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

We have to support float, since just restricting parameters to int is not really desirable. I'll make it any for now and we can see about using maybe only string in the future and doing a conversion on the duneapi side, or even QES

}

type ExecuteResponse struct {
ExecutionID string `json:"execution_id,omitempty"`
State string `json:"state,omitempty"`
Expand Down