Skip to content

Commit 7e754af

Browse files
committed
Fixing static check problems.
1 parent 1571aea commit 7e754af

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

pkg/frontend/starlark_interpreter.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ import (
2525
ujson "github.com/matrixorigin/matrixone/pkg/util/json"
2626
"go.starlark.net/starlark"
2727
"go.starlark.net/starlarkstruct"
28+
"go.starlark.net/syntax"
2829
"go.uber.org/zap"
2930
)
3031

3132
type starlarkInterpreter struct {
3233
interp *Interpreter
3334
thread *starlark.Thread
3435
predeclared starlark.StringDict
35-
outVars map[string]interface{}
36-
fn starlark.Value
3736
}
3837

3938
func convertToStarlarkValue(ctx context.Context, v any) (starlark.Value, error) {
@@ -213,7 +212,18 @@ func (interpreter *Interpreter) ExecuteStarlark(spBody string, dbName string, bg
213212
}
214213
}
215214

216-
globals, err := starlark.ExecFile(si.thread, "", spBody, si.predeclared)
215+
globals, err := starlark.ExecFileOptions(
216+
&syntax.FileOptions{
217+
While: true,
218+
TopLevelControl: true,
219+
GlobalReassign: true,
220+
Recursion: true,
221+
},
222+
si.thread,
223+
"",
224+
spBody,
225+
si.predeclared,
226+
)
217227
if err != nil {
218228
return err
219229
}

pkg/sql/plan/function/func_builtin_starlark.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
ujson "github.com/matrixorigin/matrixone/pkg/util/json"
2323
"github.com/matrixorigin/matrixone/pkg/vm/process"
2424
"go.starlark.net/starlark"
25+
"go.starlark.net/syntax"
2526
"go.uber.org/zap"
2627
)
2728

@@ -91,9 +92,18 @@ func (op *opBuiltInStarlark) buildFn(proc *process.Process, program string) erro
9192
"jq": starlark.NewBuiltin("jq", moJq),
9293
}
9394

94-
// execute the starlark program, ExecFile is deprecated but still widely used
95-
// in starlark-go repo.
96-
op.globals, err = starlark.ExecFile(op.th, "", program, op.predeclared)
95+
op.globals, err = starlark.ExecFileOptions(
96+
&syntax.FileOptions{
97+
While: true,
98+
TopLevelControl: true,
99+
GlobalReassign: true,
100+
Recursion: true,
101+
},
102+
op.th,
103+
"",
104+
program,
105+
op.predeclared,
106+
)
97107
if err != nil {
98108
return err
99109
}

0 commit comments

Comments
 (0)