MCPcopy Create free account
hub / github.com/brimdata/super / RunQuery

Function RunQuery

fuzz/fuzz.go:92–132  ·  view source on GitHub ↗
(t testing.TB, sctx *super.Context, readers []sio.Reader, querySource string, useDemand func(demandIn demand.Demand))

Source from the content-addressed store, hash-verified

90}
91
92func RunQuery(t testing.TB, sctx *super.Context, readers []sio.Reader, querySource string, useDemand func(demandIn demand.Demand)) []super.Value {
93 // Compile query
94 engine := mock.NewMockEngine(gomock.NewController(t))
95 comp := compiler.NewCompiler(engine)
96 ast, err := parser.ParseText(querySource)
97 if err != nil {
98 t.Skipf("%v", err)
99 }
100 query, err := runtime.CompileQuery(t.Context(), sctx, comp, ast, readers)
101 if err != nil {
102 t.Skipf("%v", err)
103 }
104 defer query.Pull(true)
105
106 // Infer demand
107 // TODO This is a hack and should be replaced by a cleaner interface in CompileQuery.
108 env := exec.NewEnvironment(engine, nil)
109 main, err := semantic.Analyze(t.Context(), ast, env, true)
110 if err != nil {
111 t.Skipf("%v", err)
112 }
113 if len(main.Body) > 0 {
114 demand := demand.Union(optimizer.DemandForSeq(main.Body, demand.All())...)
115 useDemand(demand)
116 }
117
118 // Run query
119 var valuesOut []super.Value
120 for {
121 vec, err := query.Pull(false)
122 require.NoError(t, err)
123 if vec == nil {
124 break
125 }
126 for _, value := range sbuf.Materialize(vec).Values() {
127 valuesOut = append(valuesOut, value.Copy())
128 }
129 }
130
131 return valuesOut
132}
133
134func CompareValues(t testing.TB, valuesExpected []super.Value, valuesActual []super.Value) {
135 t.Logf("comparing: len(expected)=%v vs len(actual)=%v", len(valuesExpected), len(valuesActual))

Callers 2

RunQueryBSUPFunction · 0.85
RunQueryCSUPFunction · 0.85

Calls 14

NewMockEngineFunction · 0.92
NewCompilerFunction · 0.92
ParseTextFunction · 0.92
CompileQueryFunction · 0.92
NewEnvironmentFunction · 0.92
AnalyzeFunction · 0.92
UnionFunction · 0.92
DemandForSeqFunction · 0.92
AllFunction · 0.92
MaterializeFunction · 0.92
ContextMethod · 0.80
PullMethod · 0.65

Tested by

no test coverage detected