Skip to content

Commit c7dcd26

Browse files
authored
add type checking (#6284)
This commit adds type checking to the semantic analyzer thus bringing static typing to dynamic data. As far as we know, this has not been done before in a general fashion in any SQL-like query language for dynamically typed data (e.g., SQL++, Asterix, search languages, etc). This works by computing fused types of each operator's output and propagating these types in a dataflow analysis. When types are unknown, the analysis flexibly models them as having any possible type. The CSUP and BSUP formats for dynamically typed data will be updated in future PRs to include fused-type information so robust type checking can be carried out for any super-structured data. Type checking for built-in functions and aggregate functions is not yet done as we need support from the functions packages to provide type signatures. This will be done in a subsequent PR. Many existing tests were updated since they had problematic type behavior. A number of new tests were added to test the type checker but coverage is light.
1 parent 525853d commit c7dcd26

36 files changed

+1260
-56
lines changed

compiler/semantic/analyzer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func Analyze(ctx context.Context, p *parser.AST, env *exec.Environment, extInput
4545
if err := t.Error(); err != nil {
4646
return nil, err
4747
}
48+
newChecker(t, dagFuncs).check(t.reporter, semSeq)
49+
if err := t.Error(); err != nil {
50+
return nil, err
51+
}
4852
main := newDagen(t.reporter).assemble(semSeq, dagFuncs)
4953
return main, t.Error()
5054
}

0 commit comments

Comments
 (0)