Skip to content

Commit 41c7c2f

Browse files
committed
Don't explicitly set perf tier, it's plan dependent
1 parent 1c1ab49 commit 41c7c2f

5 files changed

Lines changed: 49 additions & 6 deletions

File tree

cmd/query/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ func parseQueryID(arg string) (int, error) {
2323
func parsePerformance(cmd *cobra.Command) (string, error) {
2424
performance, _ := cmd.Flags().GetString("performance")
2525
switch performance {
26-
case "small", "medium", "large", "free":
26+
case "", "free", "medium", "large":
2727
return performance, nil
2828
default:
2929
return "", fmt.Errorf(
30-
"invalid performance tier %q: must be \"free\", \"small\", \"medium\" or \"large\"",
30+
"invalid performance tier %q: must be \"free\", \"medium\" or \"large\"",
3131
performance,
3232
)
3333
}

cmd/query/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func newRunCmd() *cobra.Command {
1919
"Use --no-wait to submit the execution and exit immediately with just the\n" +
2020
"execution ID; then fetch results later with 'dune execution results <execution-id>'.\n\n" +
2121
"Credits are consumed based on actual compute resources used. Use --performance\n" +
22-
"with the tier name your plan exposes via the API (e.g. community plans often use \"free\").\n\n" +
22+
"to override the tier; omit it to let the API auto-select based on your plan.\n\n" +
2323
"Important: if the query targets tables with known partition columns (returned by\n" +
2424
"'dune dataset search' or 'dune dataset search-by-contract'), ensure the SQL includes\n" +
2525
"a WHERE filter on those partition columns (e.g. WHERE block_date >= CURRENT_DATE -\n" +
@@ -35,7 +35,7 @@ func newRunCmd() *cobra.Command {
3535
}
3636

3737
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")
38-
cmd.Flags().String("performance", "medium", `engine tier name (plan-specific; community often uses "free"): "free", "small", "medium" (default), or "large"; credits reflect actual compute`)
38+
cmd.Flags().String("performance", "", `engine tier override: "free", "medium", or "large"; omit to let the API auto-select based on your plan`)
3939
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all available rows)")
4040
cmd.Flags().Bool("no-wait", false, "submit the execution and exit immediately, printing only the execution ID and state")
4141
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out")

cmd/query/run_sql.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func newRunSQLCmd() *cobra.Command {
1919
"saved query ID (e.g. for attaching visualizations).\n\n" +
2020
"By default, waits for completion (polling every 2 seconds) and displays result rows.\n" +
2121
"Use --no-wait to submit the execution and exit immediately with just the\n" +
22-
"execution ID. Credits are consumed based on actual compute resources used.\n\n" +
22+
"execution ID. Credits are consumed based on actual compute resources used.\n" +
23+
"Use --performance to override the tier; omit it to let the API auto-select based on your plan.\n\n" +
2324
"Important: if the SQL targets tables with known partition columns (returned by\n" +
2425
"'dune dataset search' or 'dune dataset search-by-contract'), include a WHERE filter\n" +
2526
"on those partition columns (e.g. WHERE block_date >= CURRENT_DATE - INTERVAL '7' DAY).\n" +
@@ -36,7 +37,7 @@ func newRunSQLCmd() *cobra.Command {
3637
cmd.Flags().String("sql", "", "the SQL query text in DuneSQL dialect (required)")
3738
_ = cmd.MarkFlagRequired("sql")
3839
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")
39-
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`)
40+
cmd.Flags().String("performance", "", `engine tier override: "free", "medium", or "large"; omit to let the API auto-select based on your plan`)
4041
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all available rows)")
4142
cmd.Flags().Bool("no-wait", false, "submit the execution and exit immediately, printing only the execution ID and state")
4243
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out")

cmd/query/run_sql_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ func TestRunSQLWithParams(t *testing.T) {
9191
assert.Equal(t, "30", captured.QueryParameters["days"])
9292
}
9393

94+
func TestRunSQLDefaultPerformance(t *testing.T) {
95+
var captured models.ExecuteSQLRequest
96+
mock := &mockClient{
97+
runSQLFn: func(req models.ExecuteSQLRequest) (dune.Execution, error) {
98+
captured = req
99+
return &mockExecution{
100+
id: "01ABC",
101+
waitGetResultsFn: func(_ time.Duration, _ int) (*models.ResultsResponse, error) {
102+
return testResultsResponse, nil
103+
},
104+
}, nil
105+
},
106+
}
107+
108+
root, _ := newTestRoot(mock)
109+
root.SetArgs([]string{"query", "run-sql", "--sql", "SELECT 1"})
110+
require.NoError(t, root.Execute())
111+
112+
assert.Equal(t, "", captured.Performance)
113+
}
114+
94115
func TestRunSQLWithPerformance(t *testing.T) {
95116
var captured models.ExecuteSQLRequest
96117
mock := &mockClient{

cmd/query/run_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@ func TestRunWithParams(t *testing.T) {
106106
assert.Equal(t, "30", captured.QueryParameters["days"])
107107
}
108108

109+
func TestRunDefaultPerformance(t *testing.T) {
110+
var captured models.ExecuteRequest
111+
mock := &mockClient{
112+
runQueryFn: func(req models.ExecuteRequest) (dune.Execution, error) {
113+
captured = req
114+
return &mockExecution{
115+
id: "01ABC",
116+
waitGetResultsFn: func(_ time.Duration, _ int) (*models.ResultsResponse, error) {
117+
return testResultsResponse, nil
118+
},
119+
}, nil
120+
},
121+
}
122+
123+
root, _ := newTestRoot(mock)
124+
root.SetArgs([]string{"query", "run", "4125432"})
125+
require.NoError(t, root.Execute())
126+
127+
assert.Equal(t, "", captured.Performance)
128+
}
129+
109130
func TestRunWithPerformance(t *testing.T) {
110131
var captured models.ExecuteRequest
111132
mock := &mockClient{

0 commit comments

Comments
 (0)