diff --git a/compiler/semantic/op.go b/compiler/semantic/op.go index df6993275..48283c41b 100644 --- a/compiler/semantic/op.go +++ b/compiler/semantic/op.go @@ -586,7 +586,13 @@ func (t *translator) semOp(o ast.Op, seq sem.Seq, inType super.Type) (sem.Seq, s case *ast.SQLOp: seq, sch := t.sqlQueryBody(o.Body, nil, seq, inType) seq, scope := sch.endScope(o.Body, seq) - return seq, scope.typ + var typ super.Type + if scope != badTable { + typ = scope.typ + } else { + typ = t.checker.unknown + } + return seq, typ case *ast.FileScan: format := t.env.ReaderOpts.Format fuser := t.checker.newFuser() diff --git a/compiler/ztests/sql/fork-type-check-err.yaml b/compiler/ztests/sql/fork-type-check-err.yaml new file mode 100644 index 000000000..96a7eab49 --- /dev/null +++ b/compiler/ztests/sql/fork-type-check-err.yaml @@ -0,0 +1,21 @@ +script: | + ! super -dynamic -s -I query.spq + +inputs: + - name: query.spq + data: | + SELECT * + FROM a.sup + | fork + ( pass ) + ( SELECT 1 ) + - name: a.sup + data: | + {a:1} + +outputs: + - name: stderr + data: | + the all-columns (*) pattern cannot be used for dynamic inputs in query.spq at line 1, column 8: + SELECT * + ~