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: 2 additions & 2 deletions cmd/query/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ func parseQueryID(arg string) (int, error) {
func parsePerformance(cmd *cobra.Command) (string, error) {
performance, _ := cmd.Flags().GetString("performance")
switch performance {
case "small", "medium", "large", "free":
case "", "free", "medium", "large":
return performance, nil
default:
return "", fmt.Errorf(
"invalid performance tier %q: must be \"free\", \"small\", \"medium\" or \"large\"",
"invalid performance tier %q: must be \"free\", \"medium\" or \"large\"",
performance,
)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/query/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func newRunCmd() *cobra.Command {
"Use --no-wait to submit the execution and exit immediately with just the\n" +
"execution ID; then fetch results later with 'dune execution results <execution-id>'.\n\n" +
"Credits are consumed based on actual compute resources used. Use --performance\n" +
"with the tier name your plan exposes via the API (e.g. community plans often use \"free\").\n\n" +
"to override the tier; omit it to let the API auto-select based on your plan.\n\n" +
"Important: if the query targets tables with known partition columns (returned by\n" +
"'dune dataset search' or 'dune dataset search-by-contract'), ensure the SQL includes\n" +
"a WHERE filter on those partition columns (e.g. WHERE block_date >= CURRENT_DATE -\n" +
Expand All @@ -35,7 +35,7 @@ func newRunCmd() *cobra.Command {
}

cmd.Flags().StringArray("param", nil, "typed query parameter in key=value format (repeatable); supported types: text, number (stringified, e.g. '30'), datetime (YYYY-MM-DD HH:mm:ss), enum")
cmd.Flags().String("performance", "medium", `engine tier name (plan-specific; community often uses "free"): "free", "small", "medium" (default), or "large"; credits reflect actual compute`)
cmd.Flags().String("performance", "", `engine tier override: "free", "medium", or "large"; omit to let the API auto-select based on your plan`)
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all available rows)")
cmd.Flags().Bool("no-wait", false, "submit the execution and exit immediately, printing only the execution ID and state")
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out")
Expand Down
5 changes: 3 additions & 2 deletions cmd/query/run_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func newRunSQLCmd() *cobra.Command {
"saved query ID (e.g. for attaching visualizations).\n\n" +
"By default, waits for completion (polling every 2 seconds) and displays result rows.\n" +
"Use --no-wait to submit the execution and exit immediately with just the\n" +
"execution ID. Credits are consumed based on actual compute resources used.\n\n" +
"execution ID. Credits are consumed based on actual compute resources used.\n" +
"Use --performance to override the tier; omit it to let the API auto-select based on your plan.\n\n" +
"Important: if the SQL targets tables with known partition columns (returned by\n" +
"'dune dataset search' or 'dune dataset search-by-contract'), include a WHERE filter\n" +
"on those partition columns (e.g. WHERE block_date >= CURRENT_DATE - INTERVAL '7' DAY).\n" +
Expand All @@ -36,7 +37,7 @@ func newRunSQLCmd() *cobra.Command {
cmd.Flags().String("sql", "", "the SQL query text in DuneSQL dialect (required)")
_ = cmd.MarkFlagRequired("sql")
cmd.Flags().StringArray("param", nil, "typed query parameter in key=value format (repeatable); supported types: text, number (stringified, e.g. '30'), datetime (YYYY-MM-DD HH:mm:ss), enum")
cmd.Flags().String("performance", "medium", `engine tier name for the execution (plan-specific; community often uses "free"): "free", "small", "medium" (default), or "large"; credits reflect actual compute`)
cmd.Flags().String("performance", "", `engine tier override: "free", "medium", or "large"; omit to let the API auto-select based on your plan`)
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all available rows)")
cmd.Flags().Bool("no-wait", false, "submit the execution and exit immediately, printing only the execution ID and state")
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out")
Expand Down
21 changes: 21 additions & 0 deletions cmd/query/run_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ func TestRunSQLWithParams(t *testing.T) {
assert.Equal(t, "30", captured.QueryParameters["days"])
}

func TestRunSQLDefaultPerformance(t *testing.T) {
var captured models.ExecuteSQLRequest
mock := &mockClient{
runSQLFn: func(req models.ExecuteSQLRequest) (dune.Execution, error) {
captured = req
return &mockExecution{
id: "01ABC",
waitGetResultsFn: func(_ time.Duration, _ int) (*models.ResultsResponse, error) {
return testResultsResponse, nil
},
}, nil
},
}

root, _ := newTestRoot(mock)
root.SetArgs([]string{"query", "run-sql", "--sql", "SELECT 1"})
require.NoError(t, root.Execute())

assert.Equal(t, "", captured.Performance)
}

func TestRunSQLWithPerformance(t *testing.T) {
var captured models.ExecuteSQLRequest
mock := &mockClient{
Expand Down
21 changes: 21 additions & 0 deletions cmd/query/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ func TestRunWithParams(t *testing.T) {
assert.Equal(t, "30", captured.QueryParameters["days"])
}

func TestRunDefaultPerformance(t *testing.T) {
var captured models.ExecuteRequest
mock := &mockClient{
runQueryFn: func(req models.ExecuteRequest) (dune.Execution, error) {
captured = req
return &mockExecution{
id: "01ABC",
waitGetResultsFn: func(_ time.Duration, _ int) (*models.ResultsResponse, error) {
return testResultsResponse, nil
},
}, nil
},
}

root, _ := newTestRoot(mock)
root.SetArgs([]string{"query", "run", "4125432"})
require.NoError(t, root.Execute())

assert.Equal(t, "", captured.Performance)
}

func TestRunWithPerformance(t *testing.T) {
var captured models.ExecuteRequest
mock := &mockClient{
Expand Down
Loading