drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdunn...@apache.org
Subject [1/3] git commit: DRILL-8 - Copy OpenDremel parser to drill sandbox
Date Sun, 21 Oct 2012 19:55:21 GMT
Updated Branches:
  refs/heads/master 62cebad8e -> 3df547ebc


DRILL-8 - Copy OpenDremel parser to drill sandbox

Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/3df547eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/3df547eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/3df547eb

Branch: refs/heads/master
Commit: 3df547ebc56e4e51a81c6a29014e5a57aac77288
Parents: be2ce8d
Author: tdunning <tdunning@apache.org>
Authored: Sun Oct 21 12:55:12 2012 -0700
Committer: tdunning <tdunning@apache.org>
Committed: Sun Oct 21 12:55:12 2012 -0700

----------------------------------------------------------------------
 .../src/org/apache/drill/parsers/DrqlParser.java   |   92 +++
 .../drill/parsers/impl/drqlantlr/AstNode.java      |   52 ++
 .../drill/parsers/impl/drqlantlr/DrqlAntlr.g       |  289 ++++++++
 .../drill/parsers/impl/drqlantlr/Parser.java       |  541 +++++++++++++++
 .../parsers/impl/drqlantlr/SemanticModel.java      |  250 +++++++
 .../apache/drill/parsers/DrqlParserAstTest.java    |   53 ++
 .../org/apache/drill/parsers/DrqlParserTest.java   |  459 ++++++++++++
 sandbox/query-parse/testdata/q1.drql               |    3 +
 sandbox/query-parse/testdata/q1.drql.ast           |    1 +
 sandbox/query-parse/testdata/q10.drql              |    1 +
 sandbox/query-parse/testdata/q10.drql.ast          |    1 +
 sandbox/query-parse/testdata/q11.drql              |    1 +
 sandbox/query-parse/testdata/q11.drql.ast          |    1 +
 sandbox/query-parse/testdata/q11.drql~             |    1 +
 sandbox/query-parse/testdata/q12.drql              |    1 +
 sandbox/query-parse/testdata/q12.drql.ast          |    1 +
 sandbox/query-parse/testdata/q13.drql              |    1 +
 sandbox/query-parse/testdata/q13.drql.ast          |    1 +
 sandbox/query-parse/testdata/q14.drql              |    1 +
 sandbox/query-parse/testdata/q14.drql.ast          |    1 +
 sandbox/query-parse/testdata/q15.drql              |    8 +
 sandbox/query-parse/testdata/q15.drql.ast          |    1 +
 sandbox/query-parse/testdata/q16.drql              |    1 +
 sandbox/query-parse/testdata/q17.drql              |    1 +
 sandbox/query-parse/testdata/q18.bql               |    3 +
 sandbox/query-parse/testdata/q18.bql~              |    3 +
 sandbox/query-parse/testdata/q1_temp.drql.sm       |    1 +
 sandbox/query-parse/testdata/q2.drql               |    3 +
 sandbox/query-parse/testdata/q2.drql.ast           |    1 +
 sandbox/query-parse/testdata/q3.drql               |    4 +
 sandbox/query-parse/testdata/q3.drql.ast           |    1 +
 sandbox/query-parse/testdata/q4.drql               |    3 +
 sandbox/query-parse/testdata/q4.drql.ast           |    1 +
 sandbox/query-parse/testdata/q4.drql~              |    3 +
 sandbox/query-parse/testdata/q5.drql               |    1 +
 sandbox/query-parse/testdata/q5.drql.ast           |    1 +
 sandbox/query-parse/testdata/q6.drql               |    1 +
 sandbox/query-parse/testdata/q6.drql.ast           |    1 +
 sandbox/query-parse/testdata/q7.drql               |    1 +
 sandbox/query-parse/testdata/q7.drql.ast           |    1 +
 sandbox/query-parse/testdata/q8.drql               |    3 +
 sandbox/query-parse/testdata/q8.drql.ast           |    1 +
 sandbox/query-parse/testdata/q9.drql               |    1 +
 sandbox/query-parse/testdata/q9.drql.ast           |    1 +
 sandbox/query-parse/testdata/query.drql            |    1 +
 45 files changed, 1798 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/src/org/apache/drill/parsers/DrqlParser.java
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/src/org/apache/drill/parsers/DrqlParser.java b/sandbox/query-parse/src/org/apache/drill/parsers/DrqlParser.java
new file mode 100644
index 0000000..19ca4b5
--- /dev/null
+++ b/sandbox/query-parse/src/org/apache/drill/parsers/DrqlParser.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2010, BigDataCraft.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.parsers;
+
+import java.util.List;
+
+//TODO add java docs
+public interface DrqlParser {
+	interface SemanticModelReader {
+		interface Symbol {
+			enum Type {
+			    TABLE, COLUMN, COLUMN_ALIAS, FUNCTION, AGG_FUNCTION
+			}
+			Type getType();
+			String getName();
+			List<String> getNameComponents();
+			boolean isAlias();
+			Symbol getAlisasedSymbol();
+			Symbol getAliasSymbol();
+		}
+		interface ResultColumn {
+			enum Scope {FULL, RECORD, COLUMN}
+			Scope getScope();
+			Symbol getColumnScope();
+			Symbol getAlias();
+			Expression getExpression();
+		}
+		interface Expression {
+				interface BinaryOp extends Expression {
+					enum Operators {CONTAINS, GREATER_THAN, GREATER_THAN_OR_EQUAL, 
+						LESS_THAN, LESS_THAN_OR_EQUAL, EQUAL, AND, OR, ADD, SUBTRACT,
+						MULTIPLY, DIVIDE}
+					Expression getLeftExpression();
+					Expression getRightExpression();
+					Operators getOperator();
+				}
+	
+				interface UnaryOp extends Expression {
+					Expression getExpression();
+					String getOperator();
+				}
+	
+				interface Constant extends Expression {
+					Object getValue();
+				}
+	
+				interface Column extends Expression {
+					Symbol getSymbol();
+				}
+	
+				interface Function extends Expression {
+					Symbol getSymbol();
+					List<Expression> getArgs();
+				}
+				
+		}
+		interface JoinOnClause {
+			interface JoinCondition {
+				Symbol getLeftSymbol();
+				Symbol getRightSymbol();
+			}
+			Symbol getTable();
+			List<JoinCondition> getJoinConditionClause();
+		}
+		
+		//Any 'from' clause item is modeled as DrqlQuery
+		boolean isJustATable(); 
+		Symbol getjustATable(); 
+		 
+		List<SemanticModelReader> getFromClause(); 
+		List<ResultColumn> getResultColumnList();
+		List<Symbol> getGroupByClause();
+		List<Symbol> getOrderByClause();
+		JoinOnClause getJoinOnClause(); 
+		Expression getWhereClause(); 
+		Integer getLimitClause(); 
+	}
+	SemanticModelReader parse(String drqlQueryText);
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/AstNode.java
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/AstNode.java b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/AstNode.java
new file mode 100644
index 0000000..59134ea
--- /dev/null
+++ b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/AstNode.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2010, BigDataCraft.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.parsers.impl.drqlantlr;
+
+/**
+*
+* This is parser-related class. 
+* This class represent a node in abstract syntax tree in dremel project
+* 
+* See ANTLR reference/books for more information.
+*
+* @author camuelg
+*/
+
+import org.antlr.runtime.Token;
+import org.antlr.runtime.tree.CommonTree;
+
+/**
+ * 
+ * AstNode class, it is so compact that can be keep here instead of interface to reduce clutter.
+ * <P>
+ * AstNode is a node in abstract syntax tree. Each node has a type and a single string value and 
+ * children nodes.
+ * <P>
+ * @see Antrl manual
+ * 
+ * 
+ * @author camuelg
+ */
+public final class AstNode extends CommonTree {
+	public AstNode(Token payload) {
+		super(payload);
+	}
+
+	@Override
+	public String toString() {
+		return super.toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/DrqlAntlr.g
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/DrqlAntlr.g b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/DrqlAntlr.g
new file mode 100644
index 0000000..18fb9c1
--- /dev/null
+++ b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/DrqlAntlr.g
@@ -0,0 +1,289 @@
+/**
+ * Copyright 2010, BigDataCraft.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar DrqlAntlr;
+
+options {output=AST; ASTLabelType=CommonTree; backtrack=false; k=1;}
+
+tokens {
+N_SELECT_STATEMENT; 
+N_SELECT; N_COLUMN; N_COLUMN_NAME; N_ALIAS; N_WITHIN; N_WITHIN_RECORD;
+N_FROM; N_TABLE; N_TABLE_NAME;
+N_JOIN; N_INNER;N_LEFTOUTER; N_JOIN_ON; N_JOIN_ON_LIST;
+N_WHERE; 
+N_GROUPBY; 
+N_HAVING; 
+N_ORDERBY; N_ASC; N_DESC;
+N_LIMIT; 
+N_EXPRESSION; N_ID; N_NAME;N_IN; N_CALL; N_OP;N_LOGICAL_OR;N_LOGICAL_AND;
+N_BITWISE_OR;N_BITWISE_XOR;N_BITWISE_AND;N_EQUAL;N_NOT_EQUAL;N_LESS_THAN;
+N_LESS_THAN_OR_EQUAL;N_GREATER_THAN;N_LOGICAL_NOT;N_BITWISE_NOT;
+N_CONTAINS;N_REMAINDER;N_GREATER_THAN_OR_EQUAL;N_BITWISE_RIGHT_SHIFT;
+N_DIVIDE;N_MULTIPLY;N_SUBSTRUCT;N_ADD;N_BITWISE_RIGHT_SHIFT;
+N_BITWISE_LEFT_SHIFT;N_IN_PARAMS;N_CALL_PARAMS;N_INT; N_FLOAT; N_STRING;
+}
+
+@header {package org.apache.drill.parsers.impl.drqlantlr.autogen;}
+
+@lexer::header {package org.apache.drill.parsers.impl.drqlantlr.autogen;}
+
+///Starting production 
+request: selectStatement (SEMICOLON!)? EOF!;
+
+//Select statement
+selectStatement: selectClause fromClause joinClause? whereClause? 
+    havingClause? groupbyClause? orderbyClause? limitClause?-> 
+        ^(N_SELECT_STATEMENT fromClause selectClause joinClause? whereClause? 
+        groupbyClause? havingClause? orderbyClause? limitClause?);
+
+//Select clause
+selectClause: SELECT columnExpr (COMMA columnExpr)* ->
+    ^(N_SELECT columnExpr+);
+    
+//Expression
+columnExpr: expr withinClause? (AS ID)? -> 
+    ^(N_COLUMN expr ^(N_ALIAS ID)? withinClause? );
+withinClause: (WITHIN (RECORD -> ^(N_WITHIN_RECORD) | columnPath ->
+	^(N_WITHIN columnPath)));
+	
+//From clause
+fromClause: FROM subSelectStatement (COMMA subSelectStatement)* ->
+    ^(N_FROM subSelectStatement+);
+subSelectStatement : (tableName | (LPAREN! selectStatement RPAREN!));
+
+//Join clause (TODO add productions)
+joinClause: joinClauseDesc JOIN joinClauseFrom ON joinConditionList ->
+    ^(N_JOIN joinClauseDesc joinClauseFrom joinConditionList);
+joinClauseDesc: (INNER?) -> ^(N_INNER) | (LEFT OUTER) -> ^(N_LEFTOUTER);
+joinClauseFrom: optionallyAliasedTable -> ^(N_TABLE optionallyAliasedTable) | 
+    aliasedSubSelectStatement -> ^(N_TABLE aliasedSubSelectStatement);
+optionallyAliasedTable: tableName (AS ID)? -> ^(N_TABLE tableName ID?);
+aliasedSubSelectStatement:	LPAREN selectStatement RPAREN AS tableName ->
+    ^(N_TABLE selectStatement tableName);
+joinConditionList:	joinCondition (LOGICAL_AND joinCondition)* ->
+    ^(N_JOIN_ON_LIST joinCondition+);
+joinCondition: a=columnPath EQUAL b=columnPath -> ^(N_JOIN_ON $a $b);
+
+//Where Clause 
+whereClause: WHERE expr -> ^(N_WHERE expr);
+
+//Groupby Clause
+groupbyClause: GROUPBY columnName (COMMA columnName)* -> 
+    ^(N_GROUPBY columnName+);
+
+//Having Clause
+havingClause: HAVING expr -> ^(N_HAVING expr);
+
+//Orderby Clause
+orderbyClause: ( ORDERBY orderbyColumnName (COMMA orderbyColumnName)*)	->
+    ^(N_ORDERBY orderbyColumnName+);
+orderbyColumnName:	columnName (ASC -> ^(N_ASC columnName) | DESC ->
+    ^(N_DESC columnName) | /* default sort order */	->	^(N_ASC columnName));
+						
+//Limit clause
+limitClause: ( LIMIT INT ) -> ^(N_LIMIT INT);
+
+///Column names
+columnPath: columnPath2 -> ^(N_ID columnPath2);
+columnPath2: columnName (DOT! columnName)*;
+columnName: ID -> ^(N_NAME ID) | STAR -> ^(N_NAME STAR);
+
+//Table names
+tablePath: tablePath2 -> ^(N_TABLE tablePath2);
+tablePath2:	tableName (DOT! tableName)*;						
+tableName: ID -> ^(N_TABLE_NAME ID);
+
+//Expressions
+expr: expr2 -> ^(N_EXPRESSION expr2);
+expr2:(a=b10e->$a) (o=b11o b=b10e -> ^($o $expr2 $b))*;
+b10e: (a=b9e->$a) (o=b10o b=b9e -> ^($o $b10e $b))*;
+b9e:  (a=b8e->$a) (o=b9o b=b8e  -> ^($o $b9e $b))*;
+b8e:  (a=b7e->$a) (o=b8o b=b7e 	-> ^($o $b8e $b))*;
+b7e:  (a=b6e->$a) (o=b7o b=b6e 	-> ^($o $b7e $b))*;
+b6e:  (a=b5e->$a) (o=b6o b=b5e 	-> ^($o $b6e $b))*;
+b5e:  (a=b4e->$a) (o=b5o b=b4e 	-> ^($o $b5e $b))*;
+b4e:  (a=b3e->$a) (o=b4o b=b3e 	-> ^($o $b4e $b))*;
+b3e:  (a=b2e->$a) (o=b3o b=b2e  -> ^($o $b3e $b))*;
+b2e:  (a=b1e->$a) (o=b2o b=b1e 	-> ^($o $b2e $b))*;
+b1e:  (a=uPrefixExpr->$a)   (o=b1o b=uPrefixExpr -> ^($o $b1e $b))*;
+uPrefixExpr: (o=uPrefixOp->^($o $uPrefixExpr))* (a=uPostfixExpr -> $a); 
+uPostfixExpr: (a=atomExpr->$a) (o=uPostfixOp -> ^($o $uPostfixExpr))*;
+atomExpr: INT -> ^(N_INT INT)
+    | FLOAT -> ^(N_FLOAT FLOAT)
+    | STRING -> ^(N_STRING STRING)  
+    | (LPAREN expr RPAREN) -> expr
+    | columnPath;
+
+//Ops
+b11o: LOGICAL_OR ->	N_LOGICAL_OR;	
+b10o: LOGICAL_AND->	N_LOGICAL_AND;
+b9o:  BITWISE_OR ->	N_BITWISE_OR;
+b8o:  BITWISE_XOR->	N_BITWISE_XOR;
+b7o:  BITWISE_AND->	N_BITWISE_AND;
+b6o:  EQUAL -> N_EQUAL | NOT_EQUAL -> N_NOT_EQUAL;
+b5o:  LESS_THAN -> N_LESS_THAN | LESS_THAN_OR_EQUAL -> N_LESS_THAN_OR_EQUAL | 
+    GREATER_THAN -> N_GREATER_THAN | 
+    GREATER_THAN_OR_EQUAL -> N_GREATER_THAN_OR_EQUAL;
+b4o: BITWISE_LEFT_SHIFT -> N_BITWISE_LEFT_SHIFT | 
+    BITWISE_RIGHT_SHIFT -> N_BITWISE_RIGHT_SHIFT;
+b3o: ADD -> N_ADD | SUBSTRUCT -> N_SUBSTRUCT;
+b2o: multiplyOp -> N_MULTIPLY | 
+    divideOp ->	N_DIVIDE | REMAINDER -> N_REMAINDER;
+b1o: CONTAINS -> N_CONTAINS; 
+uPrefixOp: BITWISE_NOT -> N_BITWISE_NOT | LOGICAL_NOT -> N_LOGICAL_NOT;
+uPostfixOp:	uPostfixOpIn | uPostfixOpCall;
+uPostfixOpIn: IN LPAREN (expr (COMMA expr)*)? RPAREN ->	^(N_IN_PARAMS expr*);
+uPostfixOpCall:	LPAREN (expr (COMMA expr)*)? RPAREN -> ^(N_CALL_PARAMS expr*);
+
+//Name clash grapheme ops
+divideOp: SLASH | DIV;
+multiplyOp: STAR;
+
+
+//Keywords
+SELECT		:	S E L E C T ;
+WITHIN		:	W I T H I N ;
+RECORD		:	R E C O R D ;
+AS			:A S ;
+FROM		:	F R O M ;
+INNER		:	I N N E R;
+LEFT		:	L E F T;
+OUTER		:	O U T E R;
+JOIN		:	J O I N;
+ON			:	O N;
+WHERE		:	W H E R E ;
+GROUPBY		:	G R O U P WS B Y;	
+HAVING		:	H A V I N G;
+ORDERBY		:	O R D E R WS B Y;
+DESC		:	D E S C;
+ASC			:	A S C;
+LIMIT		:	L I M I T;
+LOGICAL_OR 	:	O R;
+LOGICAL_AND	:	A N D;
+LOGICAL_NOT	:	N O T;
+CONTAINS 	:	C O N T A I N S ;
+IN		:	I N;
+
+//Graphemes
+BITWISE_AND : 	'&';
+BITWISE_NOT	: 	'~';
+BITWISE_OR	: 	'|';
+BITWISE_XOR : 	'^';
+EQUAL 		: 	'=' | '==';
+NOT_EQUAL 	: 	'<>' | '!=';
+LESS_THAN_OR_EQUAL:	'<=';
+LESS_THAN 	: 	'<';
+GREATER_THAN_OR_EQUAL: 	'>=';
+GREATER_THAN: 	'>';
+SLASH 		: 	'/';
+DIV			:	' D I V';
+STAR		: 	'*';
+ADD 		: 	'+';
+SUBSTRUCT 	:	'-';
+REMAINDER	: 	'%';
+BITWISE_LEFT_SHIFT: 	'<<';
+BITWISE_RIGHT_SHIFT: 	'>>';
+DOT		: 	'.'; 
+COLON		: 	':';
+COMMA		: 	',';
+SEMICOLON	: 	';';
+LPAREN 		: 	'(';
+RPAREN 		: 	')';
+LSQUARE 	: 	'[' ;
+RSQUARE 	: 	']' ;
+LCURLY 		: 	'{';
+RCURLY 		: 	'}';
+
+//Lexemes
+ID: F_ID1 | F_ID2;
+fragment F_ID1: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ;
+fragment F_ID2: '[' ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|' '|'\\'|'/'|'-'|'+'|'*'|'.'|':'|'$')* ']';
+
+INT :	'0'..'9'+
+    ;
+
+FLOAT
+    :   ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
+    |   '.' ('0'..'9')+ EXPONENT?
+    |   ('0'..'9')+ EXPONENT
+    ;
+
+COMMENT
+    :   '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;};
+
+WS  :   ( ' '
+        | '\t'
+        | '\r'
+        | '\n'
+        ) {$channel=HIDDEN;}
+    ;
+
+STRING
+    :  '\'' ( ESC_SEQ | ~('\\'|'\'') )* '\''
+    ;
+
+fragment
+EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
+
+fragment
+HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
+
+fragment
+ESC_SEQ
+    :   '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+    |   UNICODE_ESC
+    |   OCTAL_ESC
+    ;
+
+fragment
+OCTAL_ESC
+    :   '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+    |   '\\' ('0'..'7') ('0'..'7')
+    |   '\\' ('0'..'7')
+    ;
+
+fragment
+UNICODE_ESC
+    :   '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+    ;
+
+//Case insensetive letters, pretty ugly (or beautiful) but I haven't found a better way, sorry
+fragment A:('a'|'A');
+fragment B:('b'|'B');
+fragment C:('c'|'C');
+fragment D:('d'|'D');
+fragment E:('e'|'E');
+fragment F:('f'|'F');
+fragment G:('g'|'G');
+fragment H:('h'|'H');
+fragment I:('i'|'I');
+fragment J:('j'|'J');
+fragment K:('k'|'K');
+fragment L:('l'|'L');
+fragment M:('m'|'M');
+fragment N:('n'|'N');
+fragment O:('o'|'O');
+fragment P:('p'|'P');
+fragment Q:('q'|'Q');
+fragment R:('r'|'R');
+fragment S:('s'|'S');
+fragment T:('t'|'T');
+fragment U:('u'|'U');
+fragment V:('v'|'V');
+fragment W:('w'|'W');
+fragment X:('x'|'X');
+fragment Y:('y'|'Y');
+fragment Z:('z'|'Z');    
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/Parser.java
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/Parser.java b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/Parser.java
new file mode 100644
index 0000000..71c6dba
--- /dev/null
+++ b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/Parser.java
@@ -0,0 +1,541 @@
+/**
+ * Copyright 2010, BigDataCraft.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.parsers.impl.drqlantlr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenRewriteStream;
+import org.antlr.runtime.tree.CommonTreeAdaptor;
+import org.antlr.runtime.tree.Tree;
+import org.antlr.runtime.tree.TreeAdaptor;
+
+import org.apache.drill.parsers.DrqlParser;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Expression;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Expression.BinaryOp.Operators;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Symbol.Type;
+import org.apache.drill.parsers.impl.drqlantlr.SemanticModel.Symbol;
+import org.apache.drill.parsers.impl.drqlantlr.autogen.DrqlAntlrLexer;
+import org.apache.drill.parsers.impl.drqlantlr.autogen.DrqlAntlrParser;
+
+public class Parser implements DrqlParser{
+	/**
+	 * ANTLRNoCaseStringStream. //This class provides and implementation for a
+	 * case insensitive token checker //for the lexical analysis part of antlr.
+	 * By converting the token stream into //upper case at the time when lexical
+	 * rules are checked, this class ensures that the //lexical rules need to
+	 * just match the token with upper case letters as opposed to //combination
+	 * of upper case and lower case characters. This is purely used for matching
+	 * lexical //rules. The actual token text is stored in the same way as the
+	 * user input without //actually converting it into an upper case. The token
+	 * values are generated by the consume() //function of the super class
+	 * ANTLRStringStream. The LA() function is the lookahead function //and is
+	 * purely used for matching lexical rules. This also means that the grammar
+	 * will only //accept capitalized tokens in case it is run from other tools
+	 * like antlrworks which //do not have the ANTLRNoCaseStringStream
+	 * implementation.
+	 */
+	static class ANTLRNoCaseStringStream extends ANTLRStringStream {
+
+		public ANTLRNoCaseStringStream(String input) {
+			super(input);
+		}
+
+		@Override
+		public int LA(int i) {
+
+			int returnChar = super.LA(i);
+			if (returnChar == CharStream.EOF) {
+				return returnChar;
+			} else if (returnChar == 0) {
+				return returnChar;
+			}
+
+			return Character.toUpperCase((char) returnChar);
+		}
+	}
+	static final TreeAdaptor adaptor = new CommonTreeAdaptor() {
+		@Override
+		public Object create(Token payload) {
+			return new AstNode(payload);
+		}
+	};
+	@Override
+	public SemanticModel parse(String drqlQueryText) {
+    	AstNode node = parseToAst(drqlQueryText);
+    	SemanticModel query = 
+    			new SemanticModel();
+    	parseSelectStatement(node, query);
+    	return query;
+    }
+	public static AstNode parseToAst(String drQl) {
+    	try {
+    		DrqlAntlrLexer lexer = new DrqlAntlrLexer(new ANTLRNoCaseStringStream(drQl));
+			TokenRewriteStream tokens = new TokenRewriteStream(lexer);
+			DrqlAntlrParser parser = new DrqlAntlrParser(tokens);
+			parser.setTreeAdaptor(adaptor);
+			return (AstNode) parser.selectStatement().getTree();
+    	} catch(Exception ex) {
+    		throw new RuntimeException("Parsing of the query "+drQl + " has failed", ex);
+    	}
+	}
+	static void parseSelectStatement(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_SELECT_STATEMENT);
+		int count = node.getChildCount();
+		assert (count >= 2);
+		parseFromClause((AstNode) node.getChild(0), query);
+		parseSelectClause((AstNode) node.getChild(1), query);
+		int curNode = 2;
+		if (node.getChild(curNode) != null && node.getChild(curNode).getType() == DrqlAntlrParser.N_JOIN) {
+			parseJoinClause((AstNode) node.getChild(curNode), query);
+			curNode++;
+		}
+		if (node.getChild(curNode) != null && node.getChild(curNode).getType() == DrqlAntlrParser.N_WHERE) {
+			parseWhereClause((AstNode) node.getChild(curNode), query);
+			curNode++;
+		}
+		if (node.getChild(curNode) != null && node.getChild(curNode).getType() == DrqlAntlrParser.N_GROUPBY) {
+			parseGroupByClause((AstNode) node.getChild(curNode), query);
+			curNode++;		
+		}
+		if (node.getChild(curNode) != null && node.getChild(curNode).getType() == DrqlAntlrParser.N_HAVING) {
+			parseHavingClause((AstNode) node.getChild(curNode), query);
+			curNode++;		
+		}
+		if (node.getChild(curNode) != null && node.getChild(curNode).getType() == DrqlAntlrParser.N_ORDERBY) {
+			parseOrderByClause((AstNode) node.getChild(curNode), query);
+			curNode++;		
+		}
+		if (node.getChild(curNode) != null && node.getChild(curNode).getType() == DrqlAntlrParser.N_LIMIT) {
+			parseLimitClause((AstNode) node.getChild(curNode), query);
+			curNode++;		
+		}
+	}
+	static boolean parseWithinRecordClause(AstNode node, SemanticModel.ResultColumn column) {
+		assert (node.getType() == DrqlAntlrParser.N_WITHIN_RECORD);
+		column.scope = DrqlParser.SemanticModelReader.ResultColumn.Scope.RECORD;
+		return true;
+	}
+	static boolean parseWithinClause(AstNode node, SemanticModel.ResultColumn column) {
+		assert (node.getType() == DrqlAntlrParser.N_WITHIN);
+		column.scope = DrqlParser.SemanticModelReader.ResultColumn.Scope.COLUMN;
+		column.columnScope = new Symbol();
+		//column.columnScope.name = TODO add column id from AST 
+		return true;
+	}
+	static void parseColumnAlias(AstNode node, SemanticModel.ResultColumn column) {
+		assert (node.getType() == DrqlAntlrParser.N_ALIAS);
+		int count = node.getChildCount();
+		assert ((count == 1));
+		column.alias = new Symbol();
+		column.alias.name = node.getChild(0).toString();
+		column.alias.type = DrqlParser.SemanticModelReader.Symbol.Type.COLUMN_ALIAS;
+	}
+	static String idNode2String(AstNode idNode) {
+		StringBuilder ret = new StringBuilder();
+		assert (idNode.getType() == DrqlAntlrParser.N_ID);
+		assert (idNode.getChildCount() >= 1);
+		AstNode nameNode = (AstNode) idNode.getChild(0);
+		assert (nameNode.getType() == DrqlAntlrParser.N_NAME);
+		assert (nameNode.getChildCount() == 1);
+		ret.append(nameNode.getChild(0).toString());
+
+		for (int i = 1; i < idNode.getChildCount(); i++) {
+			nameNode = (AstNode) idNode.getChild(i);
+			assert (nameNode.getType() == DrqlAntlrParser.N_NAME);
+			assert (nameNode.getChildCount() == 1);
+			ret.append(".");
+			ret.append(nameNode.getChild(0).toString());
+		}
+		return ret.toString();
+	}
+	static void parseSelectClauseColumn(AstNode node, SemanticModel query) {
+		SemanticModel.ResultColumn column = new SemanticModel.ResultColumn();
+		column.scope = DrqlParser.SemanticModelReader.ResultColumn.Scope.FULL;
+		assert (node.getType() == DrqlAntlrParser.N_COLUMN);
+		assert (node.getChild(0).getType() == DrqlAntlrParser.N_EXPRESSION);
+		int count = node.getChildCount();
+		assert ((count >= 1) && (count <= 3));
+		if (count == 3) {
+			parseColumnAlias((AstNode) node.getChild(1), column);
+			if (node.getChild(2).getType() == DrqlAntlrParser.N_WITHIN)
+				parseWithinClause((AstNode) node.getChild(2), column);
+			else if (node.getChild(2).getType() == DrqlAntlrParser.N_WITHIN_RECORD)
+				parseWithinRecordClause((AstNode) node.getChild(2), column);
+		} else if (count == 2) {
+			if (node.getChild(1).getType() == DrqlAntlrParser.N_ALIAS) {
+				parseColumnAlias((AstNode) node.getChild(1), column);
+			} else if (node.getChild(1).getType() == DrqlAntlrParser.N_WITHIN)
+				parseWithinClause((AstNode) node.getChild(1), column);
+			else if (node.getChild(1).getType() == DrqlAntlrParser.N_WITHIN_RECORD)
+				parseWithinRecordClause(
+						(AstNode) node.getChild(1), column);
+			else {
+				assert (false);
+			}
+		}
+
+		DrqlParser.SemanticModelReader.Expression expression = 
+				createExpression((AstNode) node.getChild(0));
+		column.expression = expression;
+		query.resultColumnList.add(column);
+	};
+	private static void parseSelectClause(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_SELECT);
+		int columnCount = node.getChildCount();
+		assert (columnCount > 0);
+		for (int i = 0; i < columnCount; i++) {
+			parseSelectClauseColumn((AstNode) node.getChild(i), query);
+		}
+	}
+	/*
+			AstNode culmnNode = (AstNode) ;
+			assert (culmnNode.getType() == DrqlAntlrParser.N_COLUMN);
+			AstNode expressionNode = (AstNode) node.getChild(0);
+			assert (expressionNode.getType() == DrqlAntlrParser.N_EXPRESSION);
+			AstNode idNode = (AstNode) node.getChild(0);
+			assert (idNode.getType() == DrqlAntlrParser.N_ID);
+			int namesCount = idNode.getChildCount();
+			assert (namesCount >= 1);
+			for (int j = 0; j < namesCount; j++) {
+				AstNode nameNode = (AstNode) node.getChild(j);
+				assert (nameNode.getType() == DrqlAntlrParser.N_NAME);
+				SemanticModel.Symbol column = new SemanticModel.Symbol();
+				column.name = curNode.getText();
+				column.type = DrqlParser.SemanticModelReader.Symbol.Type.COLUMN;
+			}
+				query.resultColumnList.add(expression);
+				AstNode node3 = (AstNode) node2.getChild(j);
+				if (node3.getType() == DrqlAntlrParser.N_COLUMN) {
+					parseWithinClause(node3, query);
+				}
+			}
+		}
+	}*/
+	
+	
+	private static void parseFromClause(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_FROM);
+		int count = node.getChildCount();
+		assert (count > 0);
+		for (int i = 0; i < count; i++) {
+			AstNode node2 = (AstNode) node.getChild(i);
+			if (node2.getType() == DrqlAntlrParser.N_TABLE_NAME) {
+				assert (node2.getChildCount() == 1);
+				SemanticModel subQuery = new SemanticModel();
+				SemanticModel.Symbol table = new SemanticModel.Symbol();
+				table.name = node2.getChild(0).getText();
+				table.type = DrqlParser.SemanticModelReader.Symbol.Type.TABLE;
+				subQuery.justATable = table;
+				query.fromClause.add(subQuery);
+			} else if (node2.getType() == DrqlAntlrParser.N_SELECT_STATEMENT) {
+				assert (node2.getChildCount() == 1);
+				SemanticModel subQuery = new SemanticModel();
+				parseSelectStatement(node2, subQuery);
+				query.fromClause.add(subQuery);
+			} else
+				assert (false);
+		}		
+	}
+	private static void parseGroupByClause(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_GROUPBY);	
+		int count = node.getChildCount();
+		assert (count > 0);
+		for (int i = 0; i < count; i++) {
+			AstNode node2 = (AstNode) node.getChild(i);		
+			assert (node2.getChildCount() == 1);
+			SemanticModel.Symbol column = new SemanticModel.Symbol();
+			column.name = node2.getChild(0).getText();
+			column.type = DrqlParser.SemanticModelReader.Symbol.Type.COLUMN;
+			query.groupByClause.add(column);
+		}	
+	}
+	private static void parseWhereClause(AstNode node, SemanticModel query) {
+		if (node == null) {
+			return;
+		}
+		assert (node.getType() == DrqlAntlrParser.N_WHERE);
+		int count = node.getChildCount();
+		assert (count == 1);
+		AstNode node2 = (AstNode) node.getChild(0);
+		assert (node2.getType() == DrqlAntlrParser.N_EXPRESSION);
+		AstNode node3 = (AstNode) node2.getChild(0);
+		query.whereClause = createExpression(node3);
+	}
+	static Expression.Function parseFunction(AstNode node) {
+		SemanticModel.Expression.Function func = new SemanticModel.Expression.Function();
+		func.function = new SemanticModel.Symbol();
+		
+		String funcName = null;
+		List<Expression> args = new ArrayList<Expression>();
+		AstNode n2, n3;
+		
+		for (int i = 0; i < node.getChildCount(); i++) {
+			n2 = (AstNode) node.getChild(i);
+			if (n2.getType() == DrqlAntlrParser.N_EXPRESSION) {
+				n3 = (AstNode) n2.getChild(0);
+				assert(n3.getType() == DrqlAntlrParser.N_ID);
+				args.add(createExpression(n3));
+			} else { 
+				assert(n2.getType() == DrqlAntlrParser.N_ID); 
+				n3 = (AstNode) n2.getChild(0);
+				assert(n3.getType() == DrqlAntlrParser.N_NAME);
+				funcName = n3.getChild(0).getText();
+			}
+		}
+		func.function.type = Type.FUNCTION;
+		func.function.name = funcName;
+		func.args = args;
+		return func;
+	}
+	static SemanticModelReader.Expression createExpression(AstNode node) {
+		SemanticModelReader.Expression result = null;
+		SemanticModel.Expression.BinaryOp binaryOp;
+		AstNode n2, n3;
+		SemanticModel.Expression.Column column;
+		SemanticModel.Expression.Constant constant;
+		
+		switch (node.getType()) {
+		
+		case DrqlAntlrParser.N_LOGICAL_AND:
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.AND;
+			result = binaryOp;
+			break;
+		
+		case DrqlAntlrParser.N_LOGICAL_OR:
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.OR;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.N_CONTAINS:	
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.CONTAINS;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.N_GREATER_THAN:	
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.GREATER_THAN;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.N_GREATER_THAN_OR_EQUAL:	
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.GREATER_THAN_OR_EQUAL;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.EQUAL:	
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.EQUAL;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.LESS_THAN:	
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.LESS_THAN;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.LESS_THAN_OR_EQUAL:	
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.LESS_THAN_OR_EQUAL;
+			result = binaryOp;
+			break;
+		
+		case DrqlAntlrParser.N_SUBSTRUCT:
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.SUBTRACT;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.N_ADD:
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.ADD;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.N_MULTIPLY:
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.MULTIPLY;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.N_DIVIDE:
+			assert (node.getChildCount() == 2);
+			binaryOp = new SemanticModel.Expression.BinaryOp();
+			binaryOp.left = createExpression((AstNode) node.getChild(0));
+			binaryOp.right = createExpression((AstNode) node.getChild(1));
+			binaryOp.operator = Operators.DIVIDE;
+			result = binaryOp;
+			break;
+			
+		case DrqlAntlrParser.N_EXPRESSION:
+			assert(node.getChildCount() == 1);
+			n2 = (AstNode) node.getChild(0);
+			if (n2.getType() == DrqlAntlrParser.N_CALL_PARAMS) {
+				result = parseFunction(n2);
+			} else if (n2.getType() == DrqlAntlrParser.N_ID) {
+				SemanticModel.Expression.Column colExpr = new SemanticModel.Expression.Column();
+				colExpr.column = new SemanticModel.Symbol();
+				colExpr.column.name = idNode2String(n2);
+				result = colExpr;
+			} else {
+				result = createExpression(n2);
+			}
+			break;
+			
+		case DrqlAntlrParser.N_ID:
+			n2 = (AstNode) node.getChild(0);
+			assert (n2.getType() == DrqlAntlrParser.N_NAME);
+			n3 = (AstNode) n2.getChild(0);
+			assert (n3.getType() == DrqlAntlrParser.ID);
+			column = new SemanticModel.Expression.Column();
+			Symbol colSymbol = new Symbol();
+			colSymbol.name = n3.getText();
+			colSymbol.type = Type.COLUMN;
+			column.column = colSymbol;
+			result = column;
+			break;
+		
+		case DrqlAntlrParser.N_INT:
+			n2 = (AstNode) node.getChild(0);
+			assert (n2.getType() == DrqlAntlrParser.INT);
+			Integer integer = (Integer) Integer.parseInt(n2.getText());
+			constant = new SemanticModel.Expression.Constant();
+			constant.value = integer;
+			result = constant;
+			break;
+		}
+		
+		return result;
+	}
+	private static void parseLimitClause(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_LIMIT);
+		int count = node.getChildCount();
+		assert (count == 1);
+		AstNode node2 = (AstNode) node.getChild(0);
+		query.limitClause = Integer.parseInt(node2.getText());
+	}
+	private static void parseOrderByClause(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_ORDERBY);
+		int count = node.getChildCount();
+		for (int i = 0; i < count; i ++) {
+			AstNode node2 = (AstNode) node.getChild(i);
+			assert (node2.getType() == DrqlAntlrParser.N_ASC || 
+					node2.getType() == DrqlAntlrParser.N_DESC);
+			AstNode node3 = (AstNode) node2.getChild(0);
+			assert (node3.getType() == DrqlAntlrParser.N_NAME);
+			AstNode node4 = (AstNode) node3.getChild(0);
+			String columnName = node4.getText();
+			SemanticModel.Symbol column = new SemanticModel.Symbol();
+			column.name = columnName;
+			column.type = DrqlParser.SemanticModelReader.Symbol.Type.COLUMN;
+			query.orderByClause.add(column);	
+		}
+	}
+	private static void parseHavingClause(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_HAVING);
+		int count = node.getChildCount();
+		assert (count == 1);
+		AstNode node2 = (AstNode) node.getChild(0);
+		assert (node2.getType() == DrqlAntlrParser.N_EXPRESSION);
+		AstNode node3 = (AstNode) node2.getChild(0);
+		query.havingClause = createExpression(node3);
+	}
+	private static void parseJoinClause(AstNode node, SemanticModel query) {
+		assert (node.getType() == DrqlAntlrParser.N_JOIN);
+		int count = node.getChildCount();
+		assert (count == 3);
+
+        SemanticModel.Symbol table = new SemanticModel.Symbol();
+
+        Tree joinFrom = node.getChild(1);
+        if(joinFrom.getType() == DrqlAntlrParser.N_TABLE) {
+            table.name = joinFrom.getChild(0).getChild(0).getChild(0).getText();
+            table.type = DrqlParser.SemanticModelReader.Symbol.Type.TABLE;
+        }
+
+
+        Tree joinOnList = node.getChild(2);
+        ArrayList<SemanticModelReader.JoinOnClause.JoinCondition> joinConditions = new ArrayList<SemanticModelReader.JoinOnClause.JoinCondition>(joinOnList.getChildCount());
+
+        if(joinOnList.getType() == DrqlAntlrParser.N_JOIN_ON_LIST) {
+            for(int i=0; i<joinOnList.getChildCount(); i++) {
+
+                SemanticModel.JoinOnClause.JoinCondition joinCondition = new SemanticModel.JoinOnClause.JoinCondition();
+                assert(joinOnList.getChild(i).getChildCount() == 2);
+                Tree leftNode = joinOnList.getChild(i).getChild(0);
+                Tree rightNode = joinOnList.getChild(i).getChild(1);
+                SemanticModel.Symbol leftSymbol =  new SemanticModel.Symbol();
+                leftSymbol.name = idNode2String((AstNode) leftNode);
+                leftSymbol.type = Type.COLUMN;
+                SemanticModel.Symbol rightSymbol =  new Symbol();
+                rightSymbol.name = idNode2String((AstNode) rightNode);
+                rightSymbol.type = Type.COLUMN;
+
+                joinCondition.leftSymbol = leftSymbol;
+                joinCondition.rightSymbol = rightSymbol;
+
+                joinConditions.add(joinCondition);
+            }
+        }
+
+        SemanticModel.JoinOnClause joinOnClause = new SemanticModel.JoinOnClause();
+        joinOnClause.table = table;
+        joinOnClause.conditions = joinConditions;
+
+        query.joinOnClause = joinOnClause;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/SemanticModel.java
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/SemanticModel.java b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/SemanticModel.java
new file mode 100644
index 0000000..98aaf02
--- /dev/null
+++ b/sandbox/query-parse/src/org/apache/drill/parsers/impl/drqlantlr/SemanticModel.java
@@ -0,0 +1,250 @@
+package org.apache.drill.parsers.impl.drqlantlr;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.drill.parsers.DrqlParser;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader;
+
+public class SemanticModel implements SemanticModelReader {
+	static class Symbol implements SemanticModelReader.Symbol {
+		Type type;
+		String name;
+		List<String> components;
+		Symbol aliasSymbol;
+		Symbol aliasedSymbol;
+				
+		@Override
+		public Type getType() {
+			return type;
+		}
+
+		@Override
+		public String getName() {
+			return name;
+		}
+
+		@Override
+		public List<String> getNameComponents() {
+			return Collections.unmodifiableList(components);
+		}
+
+		@Override
+		public boolean isAlias() {
+			return aliasSymbol == null;
+		}
+
+		@Override
+		public SemanticModelReader.Symbol getAlisasedSymbol() {
+			return aliasedSymbol;
+		}
+
+		@Override
+		public SemanticModelReader.Symbol getAliasSymbol() {
+			return aliasSymbol;
+		}
+	}
+	static class ResultColumn 
+		implements SemanticModelReader.ResultColumn {
+		SemanticModelReader.ResultColumn.Scope scope;
+		Symbol columnScope;
+		Symbol alias;
+		SemanticModelReader.Expression expression;
+
+		@Override
+		public SemanticModelReader.Symbol getAlias() {
+			return alias;
+		}
+
+		@Override
+		public SemanticModelReader.Expression getExpression() {
+			return expression;
+		}
+
+		@Override
+		public Scope getScope() {
+			return scope;
+		}
+
+		@Override
+		public SemanticModelReader.Symbol getColumnScope() {
+			return columnScope;
+		}
+			
+	}
+	static class Expression implements SemanticModelReader.Expression{
+		static class BinaryOp 
+			implements SemanticModelReader.Expression.BinaryOp {
+	
+			SemanticModelReader.Expression left;
+			SemanticModelReader.Expression right;
+			Operators operator;
+					
+			@Override
+			public SemanticModelReader.Expression getLeftExpression() {
+				return left;
+			}
+	
+			@Override
+			public SemanticModelReader.Expression getRightExpression() {
+				return right;
+			}
+	
+			@Override
+			public Operators getOperator() {
+				return operator;
+			}
+		
+		}
+		static class UnaryOp 
+			implements SemanticModelReader.Expression.UnaryOp {
+	
+			SemanticModelReader.Expression expression;
+			String operator;
+			@Override
+			public SemanticModelReader.Expression getExpression() {
+				return expression;
+			}
+	
+			@Override
+			public String getOperator() {
+				return operator;
+			}
+		
+		}
+		static class Constant 
+			implements SemanticModelReader.Expression.Constant {
+			Object value;
+			
+			@Override
+			public Object getValue() {
+				return value;
+			}
+		}
+		
+		static class Column 
+			implements SemanticModelReader.Expression.Column {
+			Symbol column;
+	
+			@Override
+			public SemanticModelReader.Symbol getSymbol() {
+				return column;
+			}
+		
+		}
+		static class Function 
+			implements SemanticModelReader.Expression.Function {
+			Symbol function;
+			List<SemanticModelReader.Expression> args;
+			
+			Function() {
+				args = new LinkedList<SemanticModelReader.Expression>();
+			}
+			
+			@Override
+			public SemanticModelReader.Symbol getSymbol() {
+				return function;
+			}
+			@Override
+			public List<SemanticModelReader.Expression> getArgs() {
+				return args;
+			}
+		
+		}
+	}
+	public static class JoinOnClause implements SemanticModelReader.JoinOnClause {
+
+        public static class JoinCondition implements SemanticModelReader.JoinOnClause.JoinCondition {
+            SemanticModelReader.Symbol leftSymbol, rightSymbol;
+
+            public SemanticModelReader.Symbol getLeftSymbol() {
+                return leftSymbol;
+            }
+
+            public SemanticModelReader.Symbol getRightSymbol() {
+                return rightSymbol;
+            }
+        }
+
+		SemanticModelReader.Symbol table;
+		List<SemanticModelReader.JoinOnClause.JoinCondition> conditions;
+
+		JoinOnClause() {
+			conditions = new LinkedList<SemanticModelReader.JoinOnClause.JoinCondition>();
+		}
+		
+		@Override
+		public SemanticModelReader.Symbol getTable() {
+			return table;
+		}
+
+		@Override
+		public List<SemanticModelReader.JoinOnClause.JoinCondition> getJoinConditionClause() {
+			return Collections.unmodifiableList(conditions);
+		}
+		
+	}
+
+	List<SemanticModelReader.Symbol> orderByClause;
+	List<SemanticModelReader> fromClause;
+	List<SemanticModelReader.ResultColumn> resultColumnList;
+	List<SemanticModelReader.Symbol> groupByClause;
+	SemanticModelReader.JoinOnClause joinOnClause;
+	SemanticModelReader.Expression whereClause;
+	SemanticModelReader.Expression havingClause;
+	Integer limitClause;
+	SemanticModelReader.Symbol justATable;
+
+	public SemanticModel() {
+		orderByClause = new LinkedList<SemanticModelReader.Symbol>();
+		fromClause = new LinkedList<SemanticModelReader>();
+		resultColumnList = new LinkedList<SemanticModelReader.ResultColumn>();
+		groupByClause = new LinkedList<SemanticModelReader.Symbol>();
+	}
+	
+	@Override
+	public List<SemanticModelReader> getFromClause() {
+		return Collections.unmodifiableList(fromClause);
+	}
+
+	@Override
+	public List<SemanticModelReader.ResultColumn> getResultColumnList() {
+		return Collections.unmodifiableList(resultColumnList);
+	}
+
+	@Override
+	public List<SemanticModelReader.Symbol> getGroupByClause() {
+		return Collections.unmodifiableList(groupByClause);
+	}
+
+	@Override
+	public List<SemanticModelReader.Symbol> getOrderByClause() {
+		return Collections.unmodifiableList(orderByClause);
+	}
+
+	@Override
+	public SemanticModelReader.JoinOnClause getJoinOnClause() {
+		return joinOnClause;
+	}
+
+	@Override
+	public SemanticModelReader.Expression getWhereClause() {
+		return whereClause;
+	}
+
+	@Override
+	public Integer getLimitClause() {
+		return limitClause;
+	}
+
+	@Override
+	public boolean isJustATable() {
+		return justATable != null;
+	}
+
+	@Override
+	public SemanticModelReader.Symbol getjustATable() {
+		return justATable;
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserAstTest.java
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserAstTest.java b/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserAstTest.java
new file mode 100644
index 0000000..9714ce6
--- /dev/null
+++ b/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserAstTest.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2010, BigDataCraft.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.parsers;
+
+import static org.junit.Assert.*;
+
+import java.io.*;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.drill.parsers.impl.drqlantlr.AstNode;
+import org.apache.drill.parsers.impl.drqlantlr.Parser;
+import org.apache.drill.parsers.impl.drqlantlr.SemanticModel;
+import org.junit.Test;
+
+public class DrqlParserAstTest {
+
+	File getFile(String filename) {
+		return new File("testdata" + File.separatorChar + filename);
+	}
+	@Test
+	public void testQueryList() throws IOException {
+	       //tests parsing all SQL that are encountered in the documentation
+	       for(int i = 1; i <= 15; i++) {
+
+	           File tempFile = getFile("q"+i+"_temp.drql.sm");
+	           File expectedFile = getFile("q"+i+".drql.ast");
+	           File queryFile = getFile("q"+i+".drql");
+	           
+	           String query = FileUtils.readFileToString(queryFile);
+	           String ast = Parser.parseToAst(query).toStringTree();
+	           
+	           FileUtils.writeStringToFile(tempFile, ast);
+
+	           assertTrue("sm files differs",
+                       FileUtils.contentEquals(expectedFile, tempFile));
+
+	           FileUtils.forceDelete(tempFile);
+	       }
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserTest.java
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserTest.java b/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserTest.java
new file mode 100644
index 0000000..14c6232
--- /dev/null
+++ b/sandbox/query-parse/test/org/apache/drill/parsers/DrqlParserTest.java
@@ -0,0 +1,459 @@
+/**
+ * Copyright 2010, BigDataCraft.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.parsers;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.drill.parsers.impl.drqlantlr.Parser;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Expression;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Expression.BinaryOp;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Expression.BinaryOp.Operators;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Expression.Column;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Expression.Function;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.ResultColumn;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.ResultColumn.Scope;
+import org.apache.drill.parsers.DrqlParser.SemanticModelReader.Symbol;
+import org.junit.Test;
+
+public class DrqlParserTest {
+
+	File getFile(String filename) {
+		return new File("testdata" + File.separatorChar + filename);
+	}
+	void testBasicSymbol(Symbol sym, String name) {
+		assertTrue(sym.getAliasSymbol() == null);
+		String name2 = sym.getName();
+		assertTrue(name2.equals(name));	
+	}
+	void testBasicResultColumn(ResultColumn col, String name) {
+		assertTrue(col.getScope() == Scope.FULL);
+		assertTrue(col.getAlias() == null);
+		assertTrue(col.getColumnScope() == null);
+		Expression expr = col.getExpression();
+		assertTrue(expr instanceof Expression.Column);
+		Expression.Column colExpr = (Expression.Column) expr;
+		Symbol sym = colExpr.getSymbol();
+		testBasicSymbol(sym, name);
+	}
+	void testBasicTable(SemanticModelReader subQuery, String name) {
+		assertTrue(subQuery.isJustATable());
+		Symbol sym = subQuery.getjustATable();
+		testBasicSymbol(sym, name);
+	}
+	
+	@Test
+	public void testBasicQuery() throws IOException {
+		
+		String drqlQueryText = "SELECT column1 FROM table1";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 1);
+		ResultColumn col = resColList.get(0);
+		testBasicResultColumn(col, "column1");
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "table1");
+		
+		//check the rest of the model
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getOrderByClause().size() == 0);
+		assertTrue(query.getLimitClause() == null);
+	}
+	
+	void testAlias(ResultColumn col, String name) {
+		Symbol alias = col.getAlias();
+		assertTrue(alias.getName().equals(name));
+		assertTrue(alias.getType().name().equals("COLUMN_ALIAS"));
+	}
+	
+	@Test
+	public void testQuery1() throws IOException {
+		
+		String drqlQueryText = "SELECT column1 as col1, column2 FROM table1 WHERE col1 > 55 ORDER BY column2 ASC";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 2);
+		ResultColumn col1 = resColList.get(0);
+		assertTrue(col1.getScope() == Scope.FULL);
+		testAlias(col1, "col1");
+		assertTrue(col1.getColumnScope() == null);
+		Expression expr = col1.getExpression();
+		assertTrue(expr instanceof Expression.Column);
+		ResultColumn col2 = resColList.get(1);
+		testBasicResultColumn(col2, "column2");
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "table1");
+		
+		//where clause
+		Expression whereExpr = query.getWhereClause();
+		assertTrue(whereExpr instanceof Expression.BinaryOp);
+		Expression.BinaryOp whereExpr2 = (BinaryOp) query.getWhereClause();
+		assertTrue(whereExpr2.getOperator() == Operators.GREATER_THAN);
+		
+		//order by clause
+		List<Symbol> orderByClause = query.getOrderByClause();
+		assertTrue(orderByClause.size() == 1);
+		Symbol orderBy1 = orderByClause.get(0);
+		assertTrue(orderBy1.getName().equals("column2"));
+		assertTrue(orderBy1.getType().name().equals("COLUMN"));
+		
+		//check the rest of the model
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getLimitClause() == null);
+	}
+	
+	@Test
+	public void testQuery2() throws IOException {
+		
+		String drqlQueryText = 
+				"SELECT customersTable.id, customersTable.name, ordersTable.id " + 
+				"FROM customersTable " +
+				"INNER JOIN ordersTable ON customersTable.id = ordersTable.customerId";
+
+		DrqlParser parser = new Parser();
+        String ast = Parser.parseToAst(drqlQueryText).toStringTree();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+        SemanticModelReader.JoinOnClause join = query.getJoinOnClause();
+        assertNotNull(join);
+        assertTrue("ordersTable".equals(join.getTable().getName()));
+        assertTrue(join.getJoinConditionClause().size() == 1);
+        assertTrue(join.getJoinConditionClause().get(0).getLeftSymbol().getType() == Symbol.Type.COLUMN);
+        assertTrue("customersTable.id".equals(join.getJoinConditionClause().get(0).getLeftSymbol().getName()));
+        assertTrue(join.getJoinConditionClause().get(0).getRightSymbol().getType() == Symbol.Type.COLUMN);
+        assertTrue("ordersTable.customerId".equals(join.getJoinConditionClause().get(0).getRightSymbol().getName()));
+
+    }
+	
+	@Test
+	public void testQuery3() throws IOException {
+		
+		String drqlQueryText = "SELECT COUNT(f1) FROM table1";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 1);
+		ResultColumn col1 = resColList.get(0);
+		assertTrue(col1.getScope() == Scope.FULL);
+		assertTrue(col1.getAlias() == null);
+		Expression expr = col1.getExpression();
+		assertTrue(expr instanceof Expression.Function);
+		Expression.Function func = (Function) col1.getExpression();
+		assertTrue(func.getSymbol().getName().equals("COUNT"));
+		assertTrue(func.getArgs().size() == 1);
+		Expression arg1 = (Expression) func.getArgs().get(0);
+		assertTrue(arg1 instanceof Expression.Column);
+		Expression.Column arg1Column = (Column) arg1;
+		assertTrue(arg1Column.getSymbol().getName().equals("f1"));
+		assertTrue(col1.getColumnScope() == null);
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "table1");
+		
+		//check the rest of the model
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getLimitClause() == null);
+	}
+	
+	@Test
+	public void testQuery4() throws IOException {
+		
+		String drqlQueryText = "SELECT COUNT(r1.m2.f3) WITHIN r1.m2 AS cnt FROM [Table1];";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 1);
+		ResultColumn col1 = resColList.get(0);
+		assertTrue(col1.getScope() == Scope.COLUMN);
+		testAlias(col1, "cnt");
+		Expression expr = col1.getExpression();
+		assertTrue(expr instanceof Expression.Function);
+		Expression.Function func = (Function) col1.getExpression();
+		assertTrue(func.getSymbol().getName().equals("COUNT"));
+		assertTrue(func.getArgs().size() == 1);
+		Expression arg1 = (Expression) func.getArgs().get(0);
+		assertTrue(arg1 instanceof Expression.Column);
+		Expression.Column arg1Column = (Column) arg1;
+		assertTrue(arg1Column.getSymbol().getName().equals("r1"));
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "[Table1]");
+		
+		//check the rest of the model
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getLimitClause() == null);
+	}
+	
+	@Test
+	public void testQuery5() throws IOException {
+		
+		String drqlQueryText = "SELECT f1, SUM(f2) FROM [Table1] GROUP BY f1 HAVING SUM(f2) > 1000;";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 2);
+		
+		ResultColumn col1 = resColList.get(0);
+		assertTrue(col1.getScope() == Scope.FULL);
+		testBasicResultColumn(col1, "f1");
+		
+		ResultColumn col2 = resColList.get(1);
+		Expression expr = col2.getExpression();
+		assertTrue(expr instanceof Expression.Function);
+		Expression.Function func = (Function) col2.getExpression();
+		assertTrue(func.getSymbol().getName().equals("SUM"));
+		assertTrue(func.getArgs().size() == 1);
+		Expression arg1 = (Expression) func.getArgs().get(0);
+		assertTrue(arg1 instanceof Expression.Column);
+		Expression.Column arg1Column = (Column) arg1;
+		assertTrue(arg1Column.getSymbol().getName().equals("f2"));
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "[Table1]");
+		
+		//group-by clause
+		List<Symbol> groupByList = query.getGroupByClause();
+		assertTrue(groupByList.size() == 1);
+		Symbol groupBy1 = groupByList.get(0);
+		assertTrue(groupBy1.getName().equals("f1"));
+		assertTrue(groupBy1.getType().name().equals("COLUMN"));
+		
+		//check the rest of the model
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getLimitClause() == null);
+	}
+	
+	@Test
+	public void testQuery6() throws IOException {
+		
+		String drqlQueryText = "SELECT COUNT(m1.f2) WITHIN RECORD FROM table1;";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 1);
+		
+		ResultColumn col1 = resColList.get(0);
+		assertTrue(col1.getScope() == Scope.RECORD);
+		Expression expr = col1.getExpression();
+		assertTrue(expr instanceof Expression.Function);
+		Expression.Function func = (Function) col1.getExpression();
+		assertTrue(func.getSymbol().getName().equals("COUNT"));
+		assertTrue(func.getArgs().size() == 1);
+		Expression arg1 = (Expression) func.getArgs().get(0);
+		assertTrue(arg1 instanceof Expression.Column);
+		Expression.Column arg1Column = (Column) arg1;
+		assertTrue(arg1Column.getSymbol().getName().equals("m1"));
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "table1");
+		
+		//check the rest of the model
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getLimitClause() == null);
+	}
+	
+	@Test
+	public void testQuery7() throws IOException {
+		
+		String drqlQueryText = "SELECT column1 FROM table1 LIMIT 5;";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 1);
+		ResultColumn col = resColList.get(0);
+		testBasicResultColumn(col, "column1");
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "table1");
+		
+		//limit clause
+		int limitClause = query.getLimitClause();
+		assertTrue(limitClause == 5);
+		
+		//check the rest of the model
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getOrderByClause().size() == 0);
+	}
+	
+	void testColumnBinaryOpC1(ResultColumn col, Operators op) {
+		assertTrue(col.getScope() == Scope.FULL);
+		assertTrue(col.getAlias() == null);
+		assertTrue(col.getColumnScope() == null);
+		Expression expr = col.getExpression();
+		assertTrue(expr instanceof Expression.BinaryOp);
+		Expression.BinaryOp colExpr = (Expression.BinaryOp) expr;
+		assertTrue(colExpr.getOperator() == op);
+		Expression left = colExpr.getLeftExpression();
+		Expression right = colExpr.getRightExpression();
+		assertTrue(left instanceof Expression.Column);
+		assertTrue(right instanceof Expression.Constant);
+		Expression.Column leftExpr = (Expression.Column) left;
+		Expression.Constant rightExpr = (Expression.Constant) right;
+		Symbol sym = leftExpr.getSymbol();
+		testBasicSymbol(sym, "c");
+		assertTrue((Integer)rightExpr.getValue() == 1);
+	}
+	
+	@Test
+	public void testQuery8() throws IOException {
+		
+		String drqlQueryText = "SELECT c - 1, c + 1, c / 1, c * 1 FROM table1;";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 4);
+		ResultColumn col1 = resColList.get(0);
+		testColumnBinaryOpC1(col1, Operators.SUBTRACT);
+		ResultColumn col2 = resColList.get(1);
+		testColumnBinaryOpC1(col2, Operators.ADD);
+		ResultColumn col3 = resColList.get(2);
+		testColumnBinaryOpC1(col3, Operators.DIVIDE);
+		ResultColumn col4 = resColList.get(3);
+		testColumnBinaryOpC1(col4, Operators.MULTIPLY);
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "table1");
+		
+		//check the rest of the model
+		assertTrue(query.getLimitClause() == null);
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getOrderByClause().size() == 0);
+	}
+	
+	@Test
+	public void testQuery9() throws IOException {
+		
+		String drqlQueryText = "SELECT c - 1 + 2 FROM table1;";
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+
+		//result column list
+		List<ResultColumn> resColList = query.getResultColumnList();
+		assertTrue(resColList.size() == 1);
+		ResultColumn col1 = resColList.get(0);
+		assertTrue(col1.getScope() == Scope.FULL);
+		assertTrue(col1.getAlias() == null);
+		assertTrue(col1.getColumnScope() == null);
+		Expression expr = col1.getExpression();
+		assertTrue(expr instanceof Expression.BinaryOp);
+		Expression.BinaryOp colExpr = (Expression.BinaryOp) expr;
+		assertTrue(colExpr.getOperator() == Operators.ADD);
+		Expression left1 = colExpr.getLeftExpression();
+		Expression right1 = colExpr.getRightExpression();
+		assertTrue(left1 instanceof Expression.BinaryOp);
+		assertTrue(right1 instanceof Expression.Constant);
+		Expression.BinaryOp leftExpr1 = (Expression.BinaryOp) left1;
+		Expression.Constant rightExpr1 = (Expression.Constant) right1;
+		assertTrue((Integer)rightExpr1.getValue() == 2);
+		assertTrue(leftExpr1.getOperator() == Operators.SUBTRACT);
+		Expression left1_2 = leftExpr1.getLeftExpression();
+		Expression right1_2 = leftExpr1.getRightExpression();
+		Expression.Column leftExpr1_2 = (Expression.Column) left1_2;
+		Expression.Constant rightExpr1_2 = (Expression.Constant) right1_2;
+		Symbol sym = leftExpr1_2.getSymbol();
+		testBasicSymbol(sym, "c");
+		assertTrue((Integer)rightExpr1_2.getValue() == 1);
+		
+		//from clause
+		List<SemanticModelReader> subQueryList = query.getFromClause();
+		assertTrue(subQueryList.size() == 1);
+		SemanticModelReader subQuery = subQueryList.get(0);
+		testBasicTable(subQuery, "table1");
+		
+		//check the rest of the model
+		assertTrue(query.getLimitClause() == null);
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getOrderByClause().size() == 0);
+	}
+	
+	@Test
+	public void testSyntaxErrorQuery1() throws IOException {
+		
+		String drqlQueryText = "blah blah blah";
+		
+		// TODO: provide syntax error messages in g file. write this test.
+		
+		/*
+		DrqlParser parser = new Parser();
+		SemanticModelReader query = parser.parse(drqlQueryText);
+		
+		
+		//check the rest of the model
+		assertTrue(query.getResultColumnList().size() == 0);
+		assertTrue(query.getFromClause().size() == 0);
+		assertTrue(query.getGroupByClause().size() == 0);
+		assertTrue(query.getJoinOnClause() == null);
+		assertTrue(query.getLimitClause() == null);
+		assertTrue(query.getOrderByClause().size() == 0);
+		*/
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q1.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q1.drql b/sandbox/query-parse/testdata/q1.drql
new file mode 100644
index 0000000..69b1f83
--- /dev/null
+++ b/sandbox/query-parse/testdata/q1.drql
@@ -0,0 +1,3 @@
+SELECT word AS w, LENGTH(word), 3*2-1
+  FROM [bigquery/samples/shakespeare]
+  WHERE word CONTAINS 'th';
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q1.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q1.drql.ast b/sandbox/query-parse/testdata/q1.drql.ast
new file mode 100644
index 0000000..e792431
--- /dev/null
+++ b/sandbox/query-parse/testdata/q1.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [bigquery/samples/shakespeare])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME word))) (N_ALIAS w)) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME word))) (N_ID (N_NAME LENGTH))))) (N_COLUMN (N_EXPRESSION (N_SUBSTRUCT (N_MULTIPLY (N_INT 3) (N_INT 2)) (N_INT 1))))) (N_WHERE (N_EXPRESSION (N_CONTAINS (N_ID (N_NAME word)) (N_STRING 'th')))))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q10.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q10.drql b/sandbox/query-parse/testdata/q10.drql
new file mode 100644
index 0000000..6db67cc
--- /dev/null
+++ b/sandbox/query-parse/testdata/q10.drql
@@ -0,0 +1 @@
+SELECT f1, COUNT(f2), f3 FROM [Table] GROUP BY f1;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q10.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q10.drql.ast b/sandbox/query-parse/testdata/q10.drql.ast
new file mode 100644
index 0000000..7049777
--- /dev/null
+++ b/sandbox/query-parse/testdata/q10.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME f2))) (N_ID (N_NAME COUNT))))) (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f3))))) (N_GROUPBY (N_NAME f1)))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q11.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q11.drql b/sandbox/query-parse/testdata/q11.drql
new file mode 100644
index 0000000..028c02b
--- /dev/null
+++ b/sandbox/query-parse/testdata/q11.drql
@@ -0,0 +1 @@
+SELECT COUNT(*), word FROM [Table] WHERE word CONTAINS 'th' GROUP BY word LIMIT 5;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q11.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q11.drql.ast b/sandbox/query-parse/testdata/q11.drql.ast
new file mode 100644
index 0000000..98db6ae
--- /dev/null
+++ b/sandbox/query-parse/testdata/q11.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME *))) (N_ID (N_NAME COUNT))))) (N_COLUMN (N_EXPRESSION (N_ID (N_NAME word))))) (N_WHERE (N_EXPRESSION (N_CONTAINS (N_ID (N_NAME word)) (N_STRING 'th')))) (N_GROUPBY (N_NAME word)) (N_LIMIT 5))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q11.drql~
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q11.drql~ b/sandbox/query-parse/testdata/q11.drql~
new file mode 100644
index 0000000..b83a2e3
--- /dev/null
+++ b/sandbox/query-parse/testdata/q11.drql~
@@ -0,0 +1 @@
+SELECT COUNT(*), word FROM [Table] WHERE word CONTAINS 'th' GROUP_BY word LIMIT 5;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q12.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q12.drql b/sandbox/query-parse/testdata/q12.drql
new file mode 100644
index 0000000..858c85c
--- /dev/null
+++ b/sandbox/query-parse/testdata/q12.drql
@@ -0,0 +1 @@
+SELECT COUNT(f1) FROM Table;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q12.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q12.drql.ast b/sandbox/query-parse/testdata/q12.drql.ast
new file mode 100644
index 0000000..a2a5f47
--- /dev/null
+++ b/sandbox/query-parse/testdata/q12.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME Table)) (N_SELECT (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME f1))) (N_ID (N_NAME COUNT)))))))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q13.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q13.drql b/sandbox/query-parse/testdata/q13.drql
new file mode 100644
index 0000000..0d6c21a
--- /dev/null
+++ b/sandbox/query-parse/testdata/q13.drql
@@ -0,0 +1 @@
+SELECT COUNT(f1) FROM Table GROUP BY b1;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q13.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q13.drql.ast b/sandbox/query-parse/testdata/q13.drql.ast
new file mode 100644
index 0000000..60d3008
--- /dev/null
+++ b/sandbox/query-parse/testdata/q13.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME Table)) (N_SELECT (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME f1))) (N_ID (N_NAME COUNT)))))) (N_GROUPBY (N_NAME b1)))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q14.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q14.drql b/sandbox/query-parse/testdata/q14.drql
new file mode 100644
index 0000000..5abd083
--- /dev/null
+++ b/sandbox/query-parse/testdata/q14.drql
@@ -0,0 +1 @@
+SELECT COUNT(m1.f2) WITHIN RECORD FROM Table;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q14.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q14.drql.ast b/sandbox/query-parse/testdata/q14.drql.ast
new file mode 100644
index 0000000..fcc194e
--- /dev/null
+++ b/sandbox/query-parse/testdata/q14.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME Table)) (N_SELECT (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME m1) (N_NAME f2))) (N_ID (N_NAME COUNT)))) N_WITHIN_RECORD)))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q15.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q15.drql b/sandbox/query-parse/testdata/q15.drql
new file mode 100644
index 0000000..b2eab2d
--- /dev/null
+++ b/sandbox/query-parse/testdata/q15.drql
@@ -0,0 +1,8 @@
+SELECT 
+	DocId AS Id, 
+	COUNT(Name.Language.Code) WITHIN Name AS Cnt, 
+	Name.Url + ',' + Name.Language.Code AS Str
+FROM 
+	t , (select a,b from c)
+WHERE 
+	REGEXP(Name.Url, '^http') AND DocId < 20
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q15.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q15.drql.ast b/sandbox/query-parse/testdata/q15.drql.ast
new file mode 100644
index 0000000..a3edb3b
--- /dev/null
+++ b/sandbox/query-parse/testdata/q15.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME t) (N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME c)) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME a)))) (N_COLUMN (N_EXPRESSION (N_ID (N_NAME b))))))) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME DocId))) (N_ALIAS Id)) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME Name) (N_NAME Language) (N_NAME Code))) (N_ID (N_NAME COUNT)))) (N_ALIAS Cnt) (N_WITHIN (N_ID (N_NAME Name)))) (N_COLUMN (N_EXPRESSION (N_ADD (N_ADD (N_ID (N_NAME Name) (N_NAME Url)) (N_STRING ',')) (N_ID (N_NAME Name) (N_NAME Language) (N_NAME Code)))) (N_ALIAS Str))) (N_WHERE (N_EXPRESSION (N_LOGICAL_AND (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME Name) (N_NAME Url))) (N_EXPRESSION (N_STRING '^http')) (N_ID (N_NAME REGEXP))) (N_LESS_THAN (N_ID (N_NAME cId)) (N_INT 20))))))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q16.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q16.drql b/sandbox/query-parse/testdata/q16.drql
new file mode 100644
index 0000000..e7e83c1
--- /dev/null
+++ b/sandbox/query-parse/testdata/q16.drql
@@ -0,0 +1 @@
+select Links.Backward, Links.Forward, Name.Url from table
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q17.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q17.drql b/sandbox/query-parse/testdata/q17.drql
new file mode 100644
index 0000000..f3a06b1
--- /dev/null
+++ b/sandbox/query-parse/testdata/q17.drql
@@ -0,0 +1 @@
+select Name.Url from table
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q18.bql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q18.bql b/sandbox/query-parse/testdata/q18.bql
new file mode 100644
index 0000000..d5bbd72
--- /dev/null
+++ b/sandbox/query-parse/testdata/q18.bql
@@ -0,0 +1,3 @@
+SELECT x, y, z
+  FROM [bigquery/samples/shakespeare]
+  ORDER BY x, y desc;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q18.bql~
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q18.bql~ b/sandbox/query-parse/testdata/q18.bql~
new file mode 100644
index 0000000..a8a6aa1
--- /dev/null
+++ b/sandbox/query-parse/testdata/q18.bql~
@@ -0,0 +1,3 @@
+SELECT x, y, z
+  FROM [bigquery/samples/shakespeare]
+  ORDER BY x, y DESC;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q1_temp.drql.sm
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q1_temp.drql.sm b/sandbox/query-parse/testdata/q1_temp.drql.sm
new file mode 100644
index 0000000..be79f85
--- /dev/null
+++ b/sandbox/query-parse/testdata/q1_temp.drql.sm
@@ -0,0 +1 @@
+N_SELECT_STATEMENT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q2.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q2.drql b/sandbox/query-parse/testdata/q2.drql
new file mode 100644
index 0000000..50444b8
--- /dev/null
+++ b/sandbox/query-parse/testdata/q2.drql
@@ -0,0 +1,3 @@
+SELECT COUNT(*)
+  FROM [bigquery/samples/shakespeare]
+  WHERE word CONTAINS 'th';
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q2.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q2.drql.ast b/sandbox/query-parse/testdata/q2.drql.ast
new file mode 100644
index 0000000..1215bba
--- /dev/null
+++ b/sandbox/query-parse/testdata/q2.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [bigquery/samples/shakespeare])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME *))) (N_ID (N_NAME COUNT)))))) (N_WHERE (N_EXPRESSION (N_CONTAINS (N_ID (N_NAME word)) (N_STRING 'th')))))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q3.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q3.drql b/sandbox/query-parse/testdata/q3.drql
new file mode 100644
index 0000000..0eb146c
--- /dev/null
+++ b/sandbox/query-parse/testdata/q3.drql
@@ -0,0 +1,4 @@
+SELECT f1, SUM(f2)
+  FROM [Table]
+  GROUP BY f1
+  HAVING SUM(f2) > 1000;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q3.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q3.drql.ast b/sandbox/query-parse/testdata/q3.drql.ast
new file mode 100644
index 0000000..b053242
--- /dev/null
+++ b/sandbox/query-parse/testdata/q3.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME f2))) (N_ID (N_NAME SUM)))))) (N_GROUPBY (N_NAME f1)))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q4.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q4.drql b/sandbox/query-parse/testdata/q4.drql
new file mode 100644
index 0000000..9e6f420
--- /dev/null
+++ b/sandbox/query-parse/testdata/q4.drql
@@ -0,0 +1,3 @@
+SELECT f1, total
+  FROM (SELECT f1, SUM(f2) AS total from [Table] GROUP BY f1)
+  WHERE total > 1000;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q4.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q4.drql.ast b/sandbox/query-parse/testdata/q4.drql.ast
new file mode 100644
index 0000000..b525ebd
--- /dev/null
+++ b/sandbox/query-parse/testdata/q4.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME f2))) (N_ID (N_NAME SUM)))) (N_ALIAS total))) (N_GROUPBY (N_NAME f1)))) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_ID (N_NAME total))))) (N_WHERE (N_EXPRESSION (N_GREATER_THAN (N_ID (N_NAME total)) (N_INT 1000)))))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q4.drql~
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q4.drql~ b/sandbox/query-parse/testdata/q4.drql~
new file mode 100644
index 0000000..a7c3c76
--- /dev/null
+++ b/sandbox/query-parse/testdata/q4.drql~
@@ -0,0 +1,3 @@
+SELECT f1, total
+  FROM (SELECT f1, SUM(f2) AS total from [Table] GROUP BY f1)
+  WHERE total > 1000;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q5.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q5.drql b/sandbox/query-parse/testdata/q5.drql
new file mode 100644
index 0000000..2bbaf0c
--- /dev/null
+++ b/sandbox/query-parse/testdata/q5.drql
@@ -0,0 +1 @@
+SELECT f1, COUNT(m1.f2) WITHIN RECORD AS cnt FROM [Table];
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q5.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q5.drql.ast b/sandbox/query-parse/testdata/q5.drql.ast
new file mode 100644
index 0000000..0fc4972
--- /dev/null
+++ b/sandbox/query-parse/testdata/q5.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME m1) (N_NAME f2))) (N_ID (N_NAME COUNT)))) (N_ALIAS cnt) N_WITHIN_RECORD)))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q6.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q6.drql b/sandbox/query-parse/testdata/q6.drql
new file mode 100644
index 0000000..b3855a7
--- /dev/null
+++ b/sandbox/query-parse/testdata/q6.drql
@@ -0,0 +1 @@
+SELECT f1, COUNT(r1.m2.f3) WITHIN RECORD AS cnt FROM [Table];
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q6.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q6.drql.ast b/sandbox/query-parse/testdata/q6.drql.ast
new file mode 100644
index 0000000..0628b52
--- /dev/null
+++ b/sandbox/query-parse/testdata/q6.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME r1) (N_NAME m2) (N_NAME f3))) (N_ID (N_NAME COUNT)))) (N_ALIAS cnt) N_WITHIN_RECORD)))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q7.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q7.drql b/sandbox/query-parse/testdata/q7.drql
new file mode 100644
index 0000000..6ff2d6f
--- /dev/null
+++ b/sandbox/query-parse/testdata/q7.drql
@@ -0,0 +1 @@
+SELECT COUNT(r1.m2.f3) WITHIN r1.m2 AS cnt FROM [Table];
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q7.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q7.drql.ast b/sandbox/query-parse/testdata/q7.drql.ast
new file mode 100644
index 0000000..cb5d896
--- /dev/null
+++ b/sandbox/query-parse/testdata/q7.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME r1) (N_NAME m2) (N_NAME f3))) (N_ID (N_NAME COUNT)))) (N_ALIAS cnt) (N_WITHIN (N_ID (N_NAME r1) (N_NAME m2))))))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q8.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q8.drql b/sandbox/query-parse/testdata/q8.drql
new file mode 100644
index 0000000..d4c4e37
--- /dev/null
+++ b/sandbox/query-parse/testdata/q8.drql
@@ -0,0 +1,3 @@
+SELECT f1, SUM(f2)
+  FROM [Table]
+  GROUP BY f1;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q8.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q8.drql.ast b/sandbox/query-parse/testdata/q8.drql.ast
new file mode 100644
index 0000000..b053242
--- /dev/null
+++ b/sandbox/query-parse/testdata/q8.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME f2))) (N_ID (N_NAME SUM)))))) (N_GROUPBY (N_NAME f1)))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q9.drql
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q9.drql b/sandbox/query-parse/testdata/q9.drql
new file mode 100644
index 0000000..81c041e
--- /dev/null
+++ b/sandbox/query-parse/testdata/q9.drql
@@ -0,0 +1 @@
+SELECT f1, COUNT(f2) FROM [Table] GROUP BY f1, f3;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/3df547eb/sandbox/query-parse/testdata/q9.drql.ast
----------------------------------------------------------------------
diff --git a/sandbox/query-parse/testdata/q9.drql.ast b/sandbox/query-parse/testdata/q9.drql.ast
new file mode 100644
index 0000000..db708a5
--- /dev/null
+++ b/sandbox/query-parse/testdata/q9.drql.ast
@@ -0,0 +1 @@
+(N_SELECT_STATEMENT (N_FROM (N_TABLE_NAME [Table])) (N_SELECT (N_COLUMN (N_EXPRESSION (N_ID (N_NAME f1)))) (N_COLUMN (N_EXPRESSION (N_CALL_PARAMS (N_EXPRESSION (N_ID (N_NAME f2))) (N_ID (N_NAME COUNT)))))) (N_GROUPBY (N_NAME f1) (N_NAME f3)))
\ No newline at end of file


Mime
View raw message