Skip to content

Commit 13831ee

Browse files
committed
topdown: fix wall clock time init for PartialRun()
Fixes #7490. Signed-off-by: Stephan Renatus <[email protected]>
1 parent 617e096 commit 13831ee

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: v1/topdown/query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func (q *Query) PartialRun(ctx context.Context) (partials []ast.Body, support []
344344
if q.seed == nil {
345345
q.seed = rand.Reader
346346
}
347-
if !q.time.IsZero() {
347+
if q.time.IsZero() {
348348
q.time = time.Now()
349349
}
350350
if q.metrics == nil {

Diff for: v1/topdown/topdown_partial_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -4059,6 +4059,15 @@ func TestTopDownPartialEval(t *testing.T) {
40594059
},
40604060
wantQueries: []string{`"x" = input.x`},
40614061
},
4062+
{
4063+
note: "nondeterministic builtin time.now_ns() properly initiated",
4064+
query: "data.test.p",
4065+
nondeterministicBuiltins: true,
4066+
modules: []string{`package test
4067+
p if time.now_ns() > 0`,
4068+
},
4069+
wantQueries: []string{""}, // unconditional true
4070+
},
40624071
}
40634072

40644073
ctx := context.Background()

0 commit comments

Comments
 (0)