90 likes | 273 Views
The Query Compiler. Varun Sud ID: 104. Agenda. Parsing Syntax analysis and Parse Trees. Grammar for a simple subset of SQL Base Syntactic Categories The Preprocessor. Parsing. Three steps of query processor Parse SQL query into parse tree. Transform parse tree into expression tree.
E N D
The Query Compiler Varun Sud ID: 104
Agenda • Parsing • Syntax analysis and Parse Trees. • Grammar for a simple subset of SQL • Base Syntactic Categories • The Preprocessor.
Parsing • Three steps of query processor • Parse SQL query into parse tree. • Transform parse tree into expression tree. • Transform logical query plan into physical query plan.
Syntax analysis and parse trees • Parser converts SQL text to parse tree • Nodes of trees correspond to: • Atoms: lexical elements such as keywords, names of attributes or relations etc • Syntactic categories, which are names of families of query subparts.
Grammar for simple subset of SQL • Queries • <Query> ::= <SFW> • <Query> ::= (<Query>) • SFW: select from were • ::= means “can be expressed as.”
Contd. • Select-From-Where Forms • <SFW> ::= SELECT <SelList> FROM <FromList> WHERE <Condition> • Select-Lists • <SelList> ::= <Attribute> ,<SelList> • <SelList> ::= <Attribute>
Contd. • Conditions • <Condition> ::= <Condition> AND <Condition> • <Condition> ::= <Tuple> IN <Query> • <Condition> ::= <Attribute> = <Attribute> • <Condition> ::= <Attribute> LIKE <Pattern> • <Tuple> ::= <Attribute>
The Preprocessor • Preprocessor is responsible for semantic checking. • Preprocessor must: • Check relation uses. • Check and resolve attribute uses • Check types.