-
Notifications
You must be signed in to change notification settings - Fork 15
Developer guide
jonifreeman edited this page Oct 19, 2012
·
16 revisions
The sqltyped macro is a minicompiler which takes SQL string as an input and outputs Scala AST.
Compilation starts by parsing a SQL statement. Successful parsing produces Statement[Option[String]]
. Statement is internally used data type for SQL AST and is parameterized by type of table references in column definitions. For instance, in a statement SELECT name, p.age from person p
column name
has a table reference None
, and column age
has a table reference Some("p")
.
SqlParser.parse(sql: String): ?[Statement[Option[String]]
Next phase resolves all table references to point to a concrete table. For instance, in a statement SELECT name, p.age from person p
both columns reference a table Table("person")
.
Ast.resolveTables(stmt: Statement[Option[String]]): ?[Statement[Table]]
Typer.infer(stmt: Ast.Statement[Table], useInputTags: Boolean): ?[TypedStatement]
Analyzer.refine(stmt: TypedStatement): ?[TypedStatement]