You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2013/07/29 06:03:32 UTC
[03/13] TAJO-87: Integration of tajo algebra module and SQL parser
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/00c3ee2b/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLLexer.g
----------------------------------------------------------------------
diff --git a/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLLexer.g b/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLLexer.g
deleted file mode 100644
index 40a0a4d..0000000
--- a/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLLexer.g
+++ /dev/null
@@ -1,1152 +0,0 @@
-/*
- This software is made available under the BSD License:
-
- Copyright (c) 2011, Mage Systems
- Portions Copyright (c) Jonathan Leffler 2004-2009'
- Portions Copyright (c) 2003, ISO - International Organization for Standardization
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the "Mage Systems" nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
- */
-
-/*
-==============================================================================================
- Based on BNF Grammer for ISO/IEC 9075-2:2003 Database Language SQL (SQL-2003) SQL/Foundation
- Refer to http://savage.net.au/SQL/sql-2003-2.bnf.html
-==============================================================================================
-*/
-
-lexer grammar SQLLexer;
-
-options{
- language=Java;
-}
-
-@header {
-package org.apache.tajo.frontend.sql;
-
-import org.apache.tajo.frontend.sql.SQLParseError;
-}
-
-@members {
- @Override
- public void reportError(RecognitionException e) {
- throw new SQLParseError(getErrorHeader(e));
- }
-}
-
-/*
-==============================================================================================
- Comment Tokens
-==============================================================================================
-*/
-fragment
-Start_Comment : '/*';
-
-fragment
-End_Comment : '*/';
-
-fragment
-Line_Comment : '//';
-
-COMMENT
- : ( Start_Comment ( options {greedy=false;} : . )* End_Comment )+
- {
- $channel=HIDDEN;
- }
- ;
-
-LINE_COMMENT
- : ( ( Line_Comment | '--' ) ~('\n'|'\r')* '\r'? '\n')+
- {
- $channel=HIDDEN;
- }
- ;
-
-fragment
-SQL_Terminal_Character : SQL_Language_Character;
-
-fragment
-SQL_Language_Character : Simple_Latin_Letter | Digit | SQL_Special_Character;
-
-fragment
-Simple_Latin_Letter : Simple_Latin_Upper_Case_Letter | Simple_Latin_Lower_Case_Letter;
-
-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';
-
-fragment
-Simple_Latin_Upper_Case_Letter :
- 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' |
- 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
-
-fragment
-Simple_Latin_Lower_Case_Letter :
- 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' |
- 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
-
-fragment
-Digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
-
-fragment
-OctalDigit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7';
-
-fragment
-Hexit : Digit | A | B | C | D | E | F;
-
-fragment
-SQL_Special_Character :
- Space
- | Double_Quote
- | Percent
- | Ampersand
- | Quote
- | Left_Paren
- | Right_Paren
- | Asterisk
- | Plus_Sign
- | Comma
- | Minus_Sign
- | Period
- | Slash
- | Colon
- | Semicolon
- | Less_Than_Operator
- | Equals_Operator
- | Greater_Than_Operator
- | Question_Mark
- | Left_Bracket
- | Right_Bracket
- | Circumflex
- | Underscore
- | Vertical_Bar
- | Left_Brace
- | Right_Brace
- ;
-
-fragment
-Unsigned_Large_Integer
- : ;
-fragment
-Signed_Large_Integer
- : ;
-fragment
-Unsigned_Float
- : ;
-fragment
-Signed_Float
- : ;
-
-/*
-==============================================================================================
- Reserved Keyword Tokens
-==============================================================================================
-*/
-ALL : A L L;
-AS : A S;
-AND : A N D;
-
-BEGIN : B E G I N;
-BETWEEN : B E T W E E N;
-BIGINT : B I G I N T;
-BINARY : B I N A R Y;
-BLOB : B L O B;
-BOOLEAN : B O O L E A N;
-BOTH : B O T H;
-BY : B Y;
-// non-standard
-BYTE : B Y T E;
-BYTES : B Y T E S;
-
-CASE : C A S E;
-CHAR : C H A R;
-CREATE : C R E A T E;
-CROSS : C R O S S;
-CUBE : C U B E;
-
-DATE : D A T E;
-DAY : D A Y;
-DECIMAL : D E C I M A L;
-DECLARE : D E C L A R E;
-DESCRIBE : D E S C R I B E;
-DISCONNECT : D I S C O N N E C T;
-DISTINCT : D I S T I N C T;
-DOUBLE : D O U B L E;
-DROP : D R O P;
-
-ELSE : E L S E;
-END_EXEC : E N D Hyphen E X E C;
-END : E N D;
-ESCAPE : E S C A P E;
-EXCEPT : E X C E P T;
-// non-standard
-EXTERNAL : E X T E R N A L;
-
-FALSE : F A L S E;
-FETCH : F E T C H;
-FILTER : F I L T E R;
-FLOAT : F L O A T;
-FOREIGN : F O R E I G N;
-FOR : F O R;
-FREE : F R E E;
-FROM : F R O M;
-FULL : F U L L;
-FUNCTION : F U N C T I O N;
-
-IDENTITY : I D E N T I T Y;
-IMMEDIATE : I M M E D I A T E;
-INDICATOR : I N D I C A T O R;
-INNER : I N N E R;
-INOUT : I N O U T;
-INPUT : I N P U T;
-INSENSITIVE : I N S E N S I T I V E;
-INSERT : I N S E R T;
-INTEGER : I N T E G E R;
-INTERSECT : I N T E R S E C T;
-INTERVAL : I N T E R V A L;
-INTO : I N T O;
-INT : I N T;
-IN : I N;
-ISOLATION : I S O L A T I O N;
-IS : I S;
-// non standards
-IPV4 : I P V '4';
-INDEX : I N D E X;
-
-JOIN : J O I N;
-
-NATIONAL : N A T I O N A L;
-NATURAL : N A T U R A L;
-NCHAR_VARYING : N C H A R Underscore V A R Y I N G;
-NCHAR : N C H A R;
-NCLOB : N C L O B;
-NEW : N E W;
-NONE : N O N E;
-NOTFOUND : N O T F O U N D;
-NOT : N O T;
-NO : N O;
-NULL : N U L L;
-NUMERIC : N U M E R I C;
-
-LANGUAGE : L A N G U A G E;
-LEFT : L E F T;
-LIKE : L I K E;
-LOCALTIMESTAMP : L O C A L T I M E S T A M P;
-LOCALTIME : L O C A L T I M E;
-LOCAL : L O C A L;
-LIMIT : L I M I T;
-// non standards
-LOCATION : L O C A T I O N;
-
-GET : G E T;
-GLOBAL : G L O B A L;
-GRANT : G R A N T;
-GROUPING : G R O U P I N G;
-GROUP : G R O U P;
-
-HAVING : H A V I N G;
-HOUR : H O U R;
-
-OF : O F;
-ON : O N;
-ORDER : O R D E R;
-OR : O R;
-OUTER : O U T E R;
-OUTPUT : O U T P U T;
-
-RIGHT : R I G H T;
-ROLLBACK : R O L L B A C K;
-ROLLUP : R O L L U P;
-ROWS : R O W S;
-ROW : R O W;
-
-SELECT : S E L E C T;
-SET : S E T;
-SESSION : S E S S I O N;
-SIMILAR : S I M I L A R;
-SMALLINT : S M A L L I N T;
-SQL : S Q L;
-START : S T A R T;
-SYSTEM_USER : S Y S T E M Underscore U S E R;
-SYSTEM : S Y S T E M;
-// non standards
-STRING : S T R I N G;
-
-TABLE : T A B L E;
-THEN : T H E N;
-TIMESTAMP : T I M E S T A M P;
-TIMEZONE_HOUR : T I M E Z O N E Underscore H O U R;
-TIMEZONE_MINUTE : T I M E Z O N E Underscore M I N U T E;
-TIME : T I M E;
-TO : T O;
-TRUE : T R U E;
-
-UNION : U N I O N;
-UNIQUE : U N I Q U E;
-UNKNOWN : U N K N O W N;
-USER : U S E R;
-USING : U S I N G;
-
-VALUES : V A L U E S;
-VALUE : V A L U E;
-VARCHAR : V A R C H A R;
-VARYING : V A R Y I N G;
-
-WHEN : W H E N;
-WHERE : W H E R E;
-WINDOW : W I N D O W;
-WITH : W I T H;
-WITHIN : W I T H I N;
-WITHOUT : W I T H O U T;
-
-YEAR : Y E A R;
-
-/*
-==============================================================================================
- Non-Reserved Keyword Tokens
-==============================================================================================
-*/
-ASC : A S C;
-
-COUNT : C O U N T;
-
-DESC : D E S C;
-
-FINAL : F I N A L;
-FIRST : F I R S T;
-
-LAST : L A S T;
-LONG : L O N G;
-
-// Non Standard Keyword Tokens
-CLEAR : 'clear';
-DIFF : 'diff';
-
-
-/*
-==============================================================================================
- Punctuation and Arithmetic/Logical Operators
-==============================================================================================
-*/
-Not_Equals_Operator
- : '<>' | '!=' | '~='| '^=' ;
-Greater_Or_Equals_Operator
- : '>=';
-Less_Or_Equals_Operator
- : '<=';
-Concatenation_Operator
- : '||';
-Right_Arrow
- : '->';
-Double_Colon
- : '::';
-Double_Period
- : '..';
-Back_Quote
- : '`';
-Tilde
- : '~';
-Exclamation
- : '!';
-AT_Sign
- : '@';
-Percent
- : '\%';
-
-Circumflex
- : '^';
-Ampersand
- : '&';
-Asterisk
- : '*';
-Left_Paren
- : '(';
-Right_Paren
- : ')';
-Plus_Sign
- : '+';
-Minus_Sign
- : '-';
-fragment
-Hyphen
- : '-';
-Equals_Operator
- : '=';
-Left_Brace
- : '{';
-Right_Brace
- : '}';
-
-/*
-==============================================================================================
- The trigraphs are new in SQL-2003.
-==============================================================================================
-*/
-
-Left_Bracket
- : '[';
-Left_Bracket_Trigraph
- : '??(';
-Right_Bracket
- : ']';
-Right_Bracket_Trigraph
- : '??)';
-Vertical_Bar
- : '|';
-Colon
- : ':';
-Semicolon
- : ';';
-Double_Quote
- : '"';
-Quote
- : '\'';
-Less_Than_Operator
- : '<';
-Greater_Than_Operator
- : '>';
-Comma
- : ',';
-Period
- : '.';
-Question_Mark
- : '?';
-Slash
- : '/';
-
-fragment
-Underscore : '_';
-fragment
-Back_Slash : '\\';
-fragment
-Hash_Sign : '#';
-fragment
-Dollar_Sign : '$';
-
-
-// Tajo Ones
-ASSIGN : ':=';
-
-/*
-==============================================================================================
- Character Set rules
-==============================================================================================
-*/
-
-fragment
-Unicode_Permitted_Identifier_Character :
- Basic_Latin_Without_Quotes
- | Latin1_Supplement
- | Latin_ExtendedA
- | Latin_ExtendedB
- | IPA_Extensions
- | Combining_Diacritical_Marks
- | Greek_and_Coptic
- | Cyrillic
- | Cyrillic_Supplementary
- | Armenian
- | Hebrew
- | Arabic
- | Syriac
- | Thaana
- | Devanagari
- | Bengali
- | Gurmukhi
- | Gujarati
- | Oriya
- | Tamil
- | Telugu
- | Kannada
- | Malayalam
- | Sinhala
- | Thai
- | Lao
- | Tibetan
- | Myanmar
- | Georgian
- | Hangul_Jamo
- | Ethiopic
- | Cherokee
- | Unified_Canadian_Aboriginal
- | Ogham
- | Runic
- | Tagalog
- | Hanunoo
- | Buhid
- | Tagbanwa
- | Khmer
- | Mongolian
- | Limbu
- | Tai_Le
- | Khmer_Symbols
- | Phonetic_Extensions
- | Latin_Extended_Additional
- | Greek_Extended
- | Superscripts_and_Subscripts
- | Currency_Symbols
- | Combining_Diacritical_Symbol_Marks
- | Letterlike_Symbols
- | Number_Forms
- | Enclosed_Alphanumerics
- | CJK_Radicals_Supplement
- | Kangxi_Radicals
- | Ideographic_Description_Characters
- | CJK_Symbols_and_Punctuation
- | Hiragana
- | Katakana
- | Bopomofo
- | Hangul_Compatibility_Jamo
- | Kanbun
- | Bopomofo_Extended
- | Katakana_Phonetic_Extensions
- | Enclosed_CJK_Letters_and_Months
- | CJK_Compatibility
- | CJK_Unified_Ideographs_ExtensionA
- | CJK_Unified_Ideographs
- | Yi_Syllables
- | Yi_Radicals
- | Hangul_Syllables
- | High_Surrogates
- | High_Private_Use_Surrogates
- | Low_Surrogates
- | Private_Use_Area
- | CJK_Compatibility_Ideographs
- | Alphabetic_Presentation_Forms
- | Arabic_Presentation_FormsA
- | Variation_Selectors
- | Combining_Half_Marks
- | CJK_Compatibility_Forms
- | Small_Form_Variants
- | Arabic_Presentation_FormsB
- | Halfwidth_and_Fullwidth_Forms
- ;
-
-// Generate an Unexpected Token Error if any forbidden characters are used in a Unicode Identifier
-Unicode_Forbidden_Identifier_Characters : ( Unicode_Forbidden_Identifier_Character )+;
-
-fragment
-Unicode_Forbidden_Identifier_Character :
- Control_Characters
- | Spacing_Modifier_Letters
- | General_Punctuation
- | Arrows
- | Mathematical_Operators
- | Miscellaneous_Technical
- | Control_Pictures
- | Optical_Character_Recognition
- | Box_Drawing
- | Block_Elements
- | Geometric_Shapes
- | Miscellaneous_Symbols
- | Dingbats
- | Miscellaneous_Mathematical_SymbolsA
- | Supplemental_ArrowsA
- | Braille_Patterns
- | Supplemental_ArrowsB
- | Miscellaneous_Mathematical_SymbolsB
- | Supplemental_Mathematical_Operators
- | Miscellaneous_Symbols_and_Arrows
- | Yijing_Hexagram_Symbols
- | Specials
- ;
-
-// Unicode Character Ranges
-fragment
-Unicode_Character_Without_Quotes : Basic_Latin_Without_Quotes
- | '\u00A0' .. '\uFFFF';
-fragment
-Extended_Latin_Without_Quotes : '\u0001' .. '!' | '#' .. '&' | '(' .. '\u00FF';
-fragment
-Control_Characters : '\u0001' .. '\u001F';
-fragment
-Basic_Latin : '\u0020' .. '\u007F';
-fragment
-Basic_Latin_Without_Quotes : ' ' .. '!' | '#' .. '&' | '(' .. '~';
-fragment
-Regex_Non_Escaped_Unicode : ~( '|' | '*' | '+' | '-' | '?' | '\%' | '_' | '^' | ':' | '{' | '}' | '(' | ')' | '[' | '\\' ) ;
-fragment
-Regex_Escaped_Unicode : ' ' .. '[' | ']' .. '~' | '\u00A0' .. '\uFFFF';
-fragment
-Unicode_Allowed_Escape_Chracter : '!' | '#' .. '&' | '(' .. '/' | ':' .. '@' | '[' .. '`' | '{' .. '~' | '\u0080' .. '\u00BF';
-fragment
-Full_Unicode : '\u0001' .. '\uFFFF';
-fragment
-Extended_Control_Characters : '\u0080' .. '\u009F';
-fragment
-Latin1_Supplement : '\u00A0' .. '\u00FF';
-fragment
-Latin_ExtendedA : '\u0100' .. '\u017F';
-fragment
-Latin_ExtendedB : '\u0180' .. '\u024F';
-fragment
-IPA_Extensions : '\u0250' .. '\u02AF';
-fragment
-Spacing_Modifier_Letters : '\u02B0' .. '\u02FF';
-fragment
-Combining_Diacritical_Marks : '\u0300' .. '\u036F';
-fragment
-Greek_and_Coptic : '\u0370' .. '\u03FF';
-fragment
-Cyrillic : '\u0400' .. '\u04FF';
-fragment
-Cyrillic_Supplementary : '\u0500' .. '\u052F';
-fragment
-Armenian : '\u0530' .. '\u058F';
-fragment
-Hebrew : '\u0590' .. '\u05FF';
-fragment
-Arabic : '\u0600' .. '\u06FF';
-fragment
-Syriac : '\u0700' .. '\u074F';
-fragment
-Thaana : '\u0780' .. '\u07BF';
-fragment
-Devanagari : '\u0900' .. '\u097F';
-fragment
-Bengali : '\u0980' .. '\u09FF';
-fragment
-Gurmukhi : '\u0A00' .. '\u0A7F';
-fragment
-Gujarati : '\u0A80' .. '\u0AFF';
-fragment
-Oriya : '\u0B00' .. '\u0B7F';
-fragment
-Tamil : '\u0B80' .. '\u0BFF';
-fragment
-Telugu : '\u0C00' .. '\u0C7F';
-fragment
-Kannada : '\u0C80' .. '\u0CFF';
-fragment
-Malayalam : '\u0D00' .. '\u0D7F';
-fragment
-Sinhala : '\u0D80' .. '\u0DFF';
-fragment
-Thai : '\u0E00' .. '\u0E7F';
-fragment
-Lao : '\u0E80' .. '\u0EFF';
-fragment
-Tibetan : '\u0F00' .. '\u0FFF';
-fragment
-Myanmar : '\u1000' .. '\u109F';
-fragment
-Georgian : '\u10A0' .. '\u10FF';
-fragment
-Hangul_Jamo : '\u1100' .. '\u11FF';
-fragment
-Ethiopic : '\u1200' .. '\u137F';
-fragment
-Cherokee : '\u13A0' .. '\u13FF';
-fragment
-Unified_Canadian_Aboriginal : '\u1400' .. '\u167F';
-fragment
-Ogham : '\u1680' .. '\u169F';
-fragment
-Runic : '\u16A0' .. '\u16FF';
-fragment
-Tagalog : '\u1700' .. '\u171F';
-fragment
-Hanunoo : '\u1720' .. '\u173F';
-fragment
-Buhid : '\u1740' .. '\u175F';
-fragment
-Tagbanwa : '\u1760' .. '\u177F';
-fragment
-Khmer : '\u1780' .. '\u17FF';
-fragment
-Mongolian : '\u1800' .. '\u18AF';
-fragment
-Limbu : '\u1900' .. '\u194F';
-fragment
-Tai_Le : '\u1950' .. '\u197F';
-fragment
-Khmer_Symbols : '\u19E0' .. '\u19FF';
-fragment
-Phonetic_Extensions : '\u1D00' .. '\u1D7F';
-fragment
-Latin_Extended_Additional : '\u1E00' .. '\u1EFF';
-fragment
-Greek_Extended : '\u1F00' .. '\u1FFF';
-fragment
-General_Punctuation : '\u2000' .. '\u206F';
-fragment
-Superscripts_and_Subscripts : '\u2070' .. '\u209F';
-fragment
-Currency_Symbols : '\u20A0' .. '\u20CF';
-fragment
-Combining_Diacritical_Symbol_Marks : '\u20D0' .. '\u20FF';
-fragment
-Letterlike_Symbols : '\u2100' .. '\u214F';
-fragment
-Number_Forms : '\u2150' .. '\u218F';
-fragment
-Arrows : '\u2190' .. '\u21FF';
-fragment
-Mathematical_Operators : '\u2200' .. '\u22FF';
-fragment
-Miscellaneous_Technical : '\u2300' .. '\u23FF';
-fragment
-Control_Pictures : '\u2400' .. '\u243F';
-fragment
-Optical_Character_Recognition : '\u2440' .. '\u245F';
-fragment
-Enclosed_Alphanumerics : '\u2460' .. '\u24FF';
-fragment
-Box_Drawing : '\u2500' .. '\u257F';
-fragment
-Block_Elements : '\u2580' .. '\u259F';
-fragment
-Geometric_Shapes : '\u25A0' .. '\u25FF';
-fragment
-Miscellaneous_Symbols : '\u2600' .. '\u26FF';
-fragment
-Dingbats : '\u2700' .. '\u27BF';
-fragment
-Miscellaneous_Mathematical_SymbolsA : '\u27C0' .. '\u27EF';
-fragment
-Supplemental_ArrowsA : '\u27F0' .. '\u27FF';
-fragment
-Braille_Patterns : '\u2800' .. '\u28FF';
-fragment
-Supplemental_ArrowsB : '\u2900' .. '\u297F';
-fragment
-Miscellaneous_Mathematical_SymbolsB : '\u2980' .. '\u29FF';
-fragment
-Supplemental_Mathematical_Operators : '\u2A00' .. '\u2AFF';
-fragment
-Miscellaneous_Symbols_and_Arrows : '\u2B00' .. '\u2BFF';
-fragment
-CJK_Radicals_Supplement : '\u2E80' .. '\u2EFF';
-fragment
-Kangxi_Radicals : '\u2F00' .. '\u2FDF';
-fragment
-Ideographic_Description_Characters : '\u2FF0' .. '\u2FFF';
-fragment
-CJK_Symbols_and_Punctuation : '\u3000' .. '\u303F';
-fragment
-Hiragana : '\u3040' .. '\u309F';
-fragment
-Katakana : '\u30A0' .. '\u30FF';
-fragment
-Bopomofo : '\u3100' .. '\u312F';
-fragment
-Hangul_Compatibility_Jamo : '\u3130' .. '\u318F';
-fragment
-Kanbun : '\u3190' .. '\u319F';
-fragment
-Bopomofo_Extended : '\u31A0' .. '\u31BF';
-fragment
-Katakana_Phonetic_Extensions : '\u31F0' .. '\u31FF';
-fragment
-Enclosed_CJK_Letters_and_Months : '\u3200' .. '\u32FF';
-fragment
-CJK_Compatibility : '\u3300' .. '\u33FF';
-fragment
-CJK_Unified_Ideographs_ExtensionA : '\u3400' .. '\u4DBF';
-fragment
-CJK_Unified_Ideographs : '\u4E00' .. '\u9FFF';
-fragment
-Yijing_Hexagram_Symbols : '\u4DC0' .. '\u4DFF';
-fragment
-Yi_Syllables : '\uA000' .. '\uA48F';
-fragment
-Yi_Radicals : '\uA490' .. '\uA4CF';
-fragment
-Hangul_Syllables : '\uAC00' .. '\uD7AF';
-fragment
-High_Surrogates : '\uD800' .. '\uDB7F';
-fragment
-High_Private_Use_Surrogates : '\uDB80' .. '\uDBFF';
-fragment
-Low_Surrogates : '\uDC00' .. '\uDFFF';
-fragment
-Private_Use_Area : '\uE000' .. '\uF8FF';
-fragment
-CJK_Compatibility_Ideographs : '\uF900' .. '\uFAFF';
-fragment
-Alphabetic_Presentation_Forms : '\uFB00' .. '\uFB4F';
-fragment
-Arabic_Presentation_FormsA : '\uFB50' .. '\uFDFF';
-fragment
-Variation_Selectors : '\uFE00' .. '\uFE0F';
-fragment
-Combining_Half_Marks : '\uFE20' .. '\uFE2F';
-fragment
-CJK_Compatibility_Forms : '\uFE30' .. '\uFE4F';
-fragment
-Small_Form_Variants : '\uFE50' .. '\uFE6F';
-fragment
-Arabic_Presentation_FormsB : '\uFE70' .. '\uFEFF';
-fragment
-Halfwidth_and_Fullwidth_Forms : '\uFF00' .. '\uFFEF';
-fragment
-Specials : '\uFFF0' .. '\uFFFF';
-
-
-
-
-fragment
-Unicode_Identifier_Part : Unicode_Escape_Value | Unicode_Permitted_Identifier_Character;
-
-fragment
-Unicode_Escape_Value : Unicode_4_Digit_Escape_Value | Unicode_6_Digit_Escape_Value ;
-
-fragment
-Unicode_4_Digit_Escape_Value : Escape_Character Hexit Hexit Hexit Hexit ;
-
-fragment
-Unicode_6_Digit_Escape_Value : Escape_Character Plus_Sign Hexit Hexit Hexit Hexit Hexit Hexit ;
-
-Escape_Character : '\\' /* Unicode_Allowed_Escape_Chracter */ /*!! See the Syntax Rules*/;
-
-
-/*
-==============================================================================================
- 5.3 <literal> (p143)
-==============================================================================================
-*/
-
-fragment
-HexPair : Hexit Hexit;
-
-fragment
-HexQuad : Hexit Hexit Hexit Hexit;
-
-fragment
-Unsigned_Integer :
- ( '0'
- ( ( 'x' | 'X' )
- HexPair ( HexPair ( HexQuad (HexQuad HexQuad)? )? )?
- | OctalDigit ( OctalDigit )*
- | {true}?
- ( '0' )*
- )
- | ( '1'..'9' ) ( Digit )*
- );
-
-fragment
-Signed_Integer :
- ( Plus_Sign | Minus_Sign ) ( Digit )+
- ;
-
-Number :
- ( '0'
- ( ( 'x' | 'X' )
- HexPair ( HexPair ( HexQuad (HexQuad HexQuad)? )? )?
- ( ('K' | 'M' |'G')
- {
- _type = Unsigned_Large_Integer;
- }
- | {true}?
- {
- _type = Unsigned_Integer;
- }
- )
-
- | ( OctalDigit )*
- ( ('K' | 'M' |'G')
- {
- _type = Unsigned_Large_Integer;
- }
- | {true}?
- {
- _type = Unsigned_Integer;
- }
- )
-
- | Period
- ( Digit )+ ( ( 'f' | 'F' | 'd' | 'D' | 'e' | 'E' ) ( Plus_Sign | Minus_Sign )? Digit ( Digit ( Digit )? )? )?
- {
- _type = Unsigned_Float;
- }
-
- | '8'..'9' ( Digit )*
- ( ('K' | 'M' |'G')
- {
- _type = Unsigned_Large_Integer;
- }
- | {true}?
- {
- _type = Unsigned_Integer;
- }
- )
- )
- | ( Plus_Sign | Minus_Sign ) ( Digit )+
- ( Period ( Digit )+ ( ( 'f' | 'F' | 'd' | 'D' | 'e' | 'E' ) ( Plus_Sign | Minus_Sign )? Digit ( Digit ( Digit )? )? )?
- {
- _type = Signed_Float;
- }
-
- | ( ('K' | 'M' |'G')
- {
- _type = Signed_Large_Integer;
- }
- | {true}?
- {
- _type = Signed_Integer;
- }
- )
- )
- | ( '1'..'9' ) ( Digit )*
- ( Period ( Digit )+ ( ( 'f' | 'F' | 'd' | 'D' | 'e' | 'E' ) ( Plus_Sign | Minus_Sign )? Digit ( Digit ( Digit )? )? )?
- {
- _type = Unsigned_Float;
- }
-
- | ( ('K' | 'M' |'G')
- {
- _type = Unsigned_Large_Integer;
- }
- | {true}?
- {
- _type = Unsigned_Integer;
- }
- )
- )
-
- | Period
- ( Digit )+ ( ( 'f' | 'F' | 'd' | 'D' | 'e' | 'E' ) ( Plus_Sign | Minus_Sign )? Digit ( Digit ( Digit )? )? )?
- {
- _type = Unsigned_Float;
- }
- );
-
-fragment
-Character_Set_Name : ( ( ( Regular_Identifier ) Period )?
- ( Regular_Identifier ) Period )?
- Regular_Identifier ;
-
-fragment
-Character_Set : Underscore Character_Set_Name;
-
-fragment
-Character_String_Literal :
- Quote ( Extended_Latin_Without_Quotes )* Quote ( Quote ( Extended_Latin_Without_Quotes )* Quote )* {setText(getText().substring(1, getText().length()-1));}
- ;
-
-fragment
-National_Character_String_Literal :
- 'N' Quote ( Extended_Latin_Without_Quotes )* Quote ( Quote ( Extended_Latin_Without_Quotes )* Quote )*
- ;
-
-fragment
-Unicode_Character_String_Literal :
- 'U' Ampersand Quote ( Unicode_Character_Without_Quotes )* Quote ( Quote ( Unicode_Character_Without_Quotes )* Quote )*
- ;
-
-fragment
-Bit : ('0' | '1');
-
-fragment
-Bit_String_Literal :
- 'B' Quote ( Bit Bit Bit Bit Bit Bit Bit Bit )* Quote ( Quote ( Bit Bit Bit Bit Bit Bit Bit Bit )* Quote )*
- ;
-
-fragment
-Hex_String_Literal :
- 'X' Quote ( Hexit Hexit )* Quote ( Quote ( Hexit Hexit )* Quote )*
- ;
-
-String_Literal :
- ( Character_Set
- (
- Unicode_Character_String_Literal
- {
- _type = Unicode_Character_String_Literal;
- }
- | Character_String_Literal
- {
- _type = Character_String_Literal;
- }
- )
- | Bit_String_Literal
- {
- _type = Bit_String_Literal;
- }
- | Hex_String_Literal
- {
- _type = Hex_String_Literal;
- }
- | National_Character_String_Literal
- {
- _type = National_Character_String_Literal;
- }
- | Unicode_Character_String_Literal
- {
- _type = Unicode_Character_String_Literal;
- }
- | Character_String_Literal
- {
- _type = Character_String_Literal;
- }
- );
-
-/*
-==============================================================================================
- 5.4 Names and identifiers (p151)
-
- Refer to the comparison table among various commercial DBMSs.
-
- Database 1st Character Sunsequent Characters Case Sensitive Max Length
- ============ ==================== ============================ ============== ==========
- Sybase ASA Latin,'_','@','#','$' Latin,Digit,'_','@','#','$' no 128
- Sybase ASE Latin,'_','@','#' Latin,Digit,'_','@','#','$' no 255
- SQL Server Latin,'_','@','#' Latin,Digit,'_','@','#','$' no 128
- Teradata Latin,'_','#','$' Latin,Digit,'_','#','$' no 30
- MySQL Latin,Digit Latin,Digit,'_','$' yes 64
- Informix Latin,'_' Latin,Digit,'_','$' no 128
- PostgreSQL Latin,'_' Latin,Digit,'_','$' no 63
- Oracle Latin Latin,Digit,'_','#','$' no 30
- Interbase Latin Latin,Digit,'_','$' no 67
- ANSI SQL92 Latin Latin,Digit,'_' yes 128
- IBM DB2 same as ANSI SQL92 no 128
- HP Neoview same as ANSI SQL92 no 128
- ------------ -------------------- ---------------------------- -------------- ----------
- Tajo SQL Latin Latin,Digit,'_',':' no 128
-==============================================================================================
-*/
-
-Regular_Identifier : Tajo_Identifier;
-
-fragment
-Tajo_Identifier : Tajo_Identifier_Start ( Tajo_Identifier_Part )*;
-fragment
-Tajo_Identifier_Start : Simple_Latin_Letter;
-fragment
-Tajo_Identifier_Part : Simple_Latin_Letter | Digit | Underscore | Colon;
-
-/*
-==============================================================================================
- Whitespace Tokens
- ignore all control characters and non-Ascii characters that are not enclosed in quotes
-==============================================================================================
-*/
-
-Space : ' '
-{
- $channel=HIDDEN;
-};
-
-White_Space : ( Control_Characters | Extended_Control_Characters )+
-{
- $channel=HIDDEN;
-};
-
-
-BAD : . {
- //error(UNKNOWN_CHARACTER, $text);
- skip();
-} ;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/00c3ee2b/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLParser.g
----------------------------------------------------------------------
diff --git a/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLParser.g b/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLParser.g
deleted file mode 100644
index 19b078b..0000000
--- a/tajo-frontend/tajo-frontend-sql/src/main/antlr3/tajo/frontend/sql/SQLParser.g
+++ /dev/null
@@ -1,956 +0,0 @@
-/*
- This software is made available under the BSD License:
-
- Copyright (c) 2011, Mage Systems
- Portions Copyright (c) Jonathan Leffler 2004-2009'
- Portions Copyright (c) 2003, ISO - International Organization for Standardization
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the "Mage Systems" nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
- */
-
-/*
-==============================================================================================
- Based on BNF Grammer for ISO/IEC 9075-2:2003 Database Language SQL (SQL-2003) SQL/Foundation
- Refer to http://savage.net.au/SQL/sql-2003-2.bnf.html
-==============================================================================================
-*/
-
-parser grammar SQLParser;
-
-options {
- language=Java;
- tokenVocab=SQLLexer;
- backtrack=true;
- memoize=true;
- output=AST;
- ASTLabelType=CommonTree;
-}
-
-tokens {
- ALL;
- COLUMN;
- COUNT_VAL;
- COUNT_ROWS;
- CREATE_INDEX;
- CREATE_TABLE;
- DROP_TABLE;
- DESC_TABLE;
- EMPTY_GROUPING_SET;
- FIELD_NAME;
- FIELD_DEF;
- FUNCTION;
- FUNC_ARGS;
- GROUP_BY;
- NULL_ORDER;
- ORDER;
- ORDER_BY;
- PARAM;
- PARAMS;
- SEL_LIST;
- SESSION_CLEAR;
- SET_QUALIFIER;
- SHOW_TABLE;
- SHOW_FUNCTION;
- SORT_KEY;
- SORT_SPECIFIERS;
- STORE;
- STORE_TYPE;
- SUBQUERY;
- TABLE_DEF;
- TARGET_FIELDS;
-}
-
-@header {
-package org.apache.tajo.frontend.sql;
-
-import java.util.List;
-import java.util.ArrayList;
-import org.apache.tajo.frontend.sql.SQLParseError;
-}
-
-@members {
- @Override
- public void reportError(RecognitionException e) {
- throw new SQLParseError(getErrorHeader(e));
- }
-
- @Override
- public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
- String hdr = getErrorHeader(e);
- String msg = getErrorMessage(e, tokenNames);
- throw new SQLParseError(hdr + ":" + msg);
- }
-}
-
-// SQL Main
-sql
- : statement EOF
- ;
-
-statement
- : sessionStatement
- | dataStatement
- | dataChangeStatement
- | schemaStatement
- | indexStatement
- ;
-
-sessionStatement
- : SESSION CLEAR -> ^(SESSION_CLEAR)
- ;
-
-dataStatement
- : query_expression
- | set_stmt
- ;
-
-dataChangeStatement
- : insertStmt
- ;
-
-schemaStatement
- : createTableStatement
- | DROP TABLE table_name -> ^(DROP_TABLE table_name)
- ;
-
-indexStatement
- : CREATE (u=UNIQUE)? INDEX n=identifier ON t=table_name (m=method_specifier)?
- Left_Paren s=sort_specifier_list Right_Paren p=param_clause?
- -> ^(CREATE_INDEX $u? $m? $p? $n $t $s)
- ;
-
-createTableStatement
- : CREATE EXTERNAL TABLE t=table_name def=tableElements USING f=identifier p=param_clause? (LOCATION path=Character_String_Literal)
- -> ^(CREATE_TABLE $t EXTERNAL ^(TABLE_DEF $def) ^(USING $f) $p? ^(LOCATION $path))
- | CREATE TABLE t=table_name (def=tableElements)? (USING f=identifier)? (p=param_clause)? (AS q=query_expression)?
- -> ^(CREATE_TABLE $t ^(TABLE_DEF $def)? ^(USING $f)? $p? ^(AS $q)?)
- ;
-
-tableElements
- : Left_Paren fieldElement (Comma fieldElement)* Right_Paren -> fieldElement+
- ;
-
-fieldElement
- : identifier fieldType -> ^(FIELD_DEF identifier fieldType)
- ;
-
-fieldType
- : BOOL
- | BYTE
- | CHAR
- | INT
- | LONG
- | FLOAT
- | DOUBLE
- | TEXT
- | DATE
- | BYTES
- | IPv4
- | VARCHAR
- | STRING
- ;
-
-query_expression
- : query_expression_body
- ;
-
-query_expression_body
- : non_join_query_expression
- | joined_table
- ;
-
-non_join_query_expression
- : (non_join_query_term | joined_table (UNION | EXCEPT)^ (ALL|DISTINCT)? query_term)
- ((UNION | EXCEPT)^ (ALL|DISTINCT)? query_term)*
- ;
-
-query_term
- : non_join_query_term
- | joined_table
- ;
-
-non_join_query_term
- : ( non_join_query_primary | joined_table INTERSECT^ (ALL|DISTINCT)? query_primary)
- (INTERSECT^ (ALL|DISTINCT)? query_primary)*
- ;
-
-query_primary
- : non_join_query_primary
- | joined_table
- ;
-
-non_join_query_primary
- : simple_table
- | Left_Paren non_join_query_expression Right_Paren
- ;
-
-simple_table
-options {k=1;}
- : query_specification
- ;
-
-query_specification
- : SELECT setQualifier? selectList from_clause? where_clause? groupby_clause? having_clause?
- orderby_clause? limit_clause?
-
- -> ^(SELECT from_clause? setQualifier? selectList where_clause? groupby_clause? having_clause?
- orderby_clause? limit_clause?)
- ;
-
-insertStmt
- : INSERT INTO table_name (Left_Paren column_reference Right_Paren)? VALUES array
- -> ^(INSERT ^(TABLE table_name) ^(VALUES array) ^(TARGET_FIELDS column_reference)?)
- ;
-
-selectList
- : Asterisk -> ^(SEL_LIST ALL)
- | derivedColumn (Comma derivedColumn)* -> ^(SEL_LIST derivedColumn+)
- ;
-
-setQualifier
- : DISTINCT -> ^(SET_QUALIFIER DISTINCT)
- | ALL -> ^(SET_QUALIFIER ALL)
- ;
-
-derivedColumn
- : value_expression asClause? -> ^(COLUMN value_expression asClause?)
- ;
-
-fieldName
- : (t=identifier Period)? b=identifier -> ^(FIELD_NAME $b $t?)
- ;
-
-asClause
- : (AS)? fieldName
- ;
-
-column_reference
- : fieldName (Comma fieldName)* -> fieldName+
- ;
-
-funcCall
- : identifier Left_Paren Right_Paren -> ^(FUNCTION[$identifier.text])
- | identifier Left_Paren funcArgs? Right_Paren -> ^(FUNCTION[$identifier.text] funcArgs?)
- | COUNT Left_Paren funcArgs Right_Paren -> ^(COUNT_VAL funcArgs)
- | COUNT Left_Paren Asterisk Right_Paren -> ^(COUNT_ROWS)
- ;
-
-funcArgs
- : value_expression (Comma value_expression)* -> value_expression+
- ;
-
-from_clause
- : FROM^ table_reference_list
- ;
-
-table_reference_list
- : table_reference (Comma table_reference)* -> table_reference+
- ;
-
-table_reference
- : joined_table
- | table_primary
- ;
-
-joined_table
- : table_primary (
- cross_join
- | qualified_join
- | natural_join
- | union_join )+
- ;
-
-joined_table_prim
- : cross_join
- | qualified_join
- | natural_join
- | union_join
- ;
-
-cross_join
- : CROSS JOIN r=table_primary -> ^(JOIN CROSS $r)
- ;
-
-qualified_join
- : (t=join_type)? JOIN r=table_primary s=join_specification -> ^(JOIN $t? $r $s)
- ;
-
-natural_join
- : NATURAL (t=join_type)? JOIN r=table_primary -> ^(JOIN NATURAL $t? $r)
- ;
-
-union_join
- : UNION JOIN r=table_primary -> ^(JOIN UNION $r)
- ;
-
-join_type
- options {k=1;}
- : INNER
- | t=outer_join_type -> ^(OUTER $t)
- ;
-
-outer_join_type
- : outer_join_type_part2 (OUTER?)!
- ;
-
-outer_join_type_part2
- : LEFT
- | RIGHT
- | FULL
- ;
-
-join_specification
- : join_condition
- | named_columns_join
- ;
-
-join_condition
- : ON^ search_condition
- ;
-
-named_columns_join
- : USING Left_Paren f=column_reference Right_Paren -> ^(USING $f)
- ;
-
-table_primary
- : table_name ((AS)? a=identifier)? -> ^(TABLE table_name ($a)?)
- | t=derived_table (AS)? a=identifier-> ^(SUBQUERY $t $a)
- ;
-
-derived_table
- : table_subquery
- ;
-
-
-
-where_clause
- : WHERE^ search_condition
- ;
-
-groupby_clause
- : GROUP BY g=grouping_element_list -> ^(GROUP_BY $g)
- ;
-
-grouping_element_list
- : grouping_element (Comma grouping_element)* -> grouping_element+
- ;
-
-grouping_element
- : ordinary_grouping_set
- | rollup_list
- | cube_list
- | empty_grouping_set
- ;
-
-ordinary_grouping_set
- : column_reference
- | Left_Paren! column_reference Right_Paren!
- ;
-
-rollup_list
- : ROLLUP Left_Paren c=ordinary_grouping_set Right_Paren -> ^(ROLLUP $c)
- ;
-
-cube_list
- : CUBE Left_Paren c=ordinary_grouping_set Right_Paren -> ^(CUBE $c)
- ;
-
-empty_grouping_set
- : Left_Paren Right_Paren -> ^(EMPTY_GROUPING_SET)
- ;
-
-having_clause
- : HAVING^ boolean_value_expression
- ;
-
-orderby_clause
- : ORDER BY sort_specifier_list -> ^(ORDER_BY sort_specifier_list)
- ;
-
-sort_specifier_list
- : sort_specifier (Comma sort_specifier)* -> ^(SORT_SPECIFIERS sort_specifier+)
- ;
-
-sort_specifier
- : fn=fieldName a=order_specification? o=null_ordering? -> ^(SORT_KEY $fn $a? $o?)
- ;
-
-order_specification
- : ASC -> ^(ORDER ASC)
- | DESC -> ^(ORDER DESC)
- ;
-
-limit_clause
- : LIMIT e=numeric_value_expression -> ^(LIMIT $e)
- ;
-
-null_ordering
- : NULL FIRST -> ^(NULL_ORDER FIRST)
- | NULL LAST -> ^(NULL_ORDER LAST)
- ;
-
-set_stmt
- : SET (UNION|INTERSECT|DIFF) table_name
- ;
-
-search_condition
- : boolean_value_expression
- ;
-
-param_clause
- : WITH Left_Paren param (Comma param)* Right_Paren -> ^(PARAMS param+)
- ;
-
-param
- : k=Character_String_Literal Equals_Operator v=boolean_value_expression -> ^(PARAM $k $v)
- ;
-
-method_specifier
- : USING m=identifier -> ^(USING[$m.text])
- ;
-
-/*
-==============================================================================================
- 5.3 <literal> (p143)
-
- Progress: Almost done
-
- TODO:
- * literal should be fixed
- * NULL should be removed
-==============================================================================================
-*/
-
-literal
- options{k=1;}
- : general_literal
- ;
-
-unsigned_literal
- : unsigned_numerical_literal
- | general_literal
- ;
-
-general_literal
- options{k=1;}
- : unsigned_numerical_literal
- | Character_String_Literal
- | National_Character_String_Literal
- | Bit_String_Literal
- | Hex_String_Literal
- | boolean_literal
- | day_time_literal
- | interval_literal
- | NULL
- ;
-
-boolean_literal
- : TRUE | FALSE | UNKNOWN
- ;
-
-signed_numerical_literal
- : Signed_Integer
- | Signed_Large_Integer
- | Signed_Float
- ;
-
-unsigned_numerical_literal
- : Unsigned_Integer
- | Unsigned_Large_Integer
- | Unsigned_Float
- ;
-
-
-/*
-==============================================================================================
- 5.4 Names and identifiers (p151)
-==============================================================================================
-*/
-
-identifier : Regular_Identifier | Unicode_Identifier;
-sql_language_identifier : Regular_Identifier;
-user_identifier : Regular_Identifier;
-schema_name : identifier ( Period identifier )? ;
-fully_qualified_identifier : identifier ( Period identifier ( Period identifier )? )?;
-
-
-table_name
- : identifier ( Period identifier ( Period identifier )? )?
- ;
-
-identifier_chain : identifier ( Period identifier )*;
-
-/*
-==============================================================================================
- 6.25 value_expression (p236)
-
- Specify a value.
-
- TODO:
- * collection_value_expression
- * collection_value_constructor
-==============================================================================================
-*/
-
-
-value_expression
-options{k=2;}
- : common_value_expression
- | boolean_value_expression
- | row_value_expression
- ;
-
-common_value_expression
-options {k=1;}
- : numeric_value_expression
- | string_value_expression
- ;
-
-user_defined_type_value_expression
- options {k=1;}
- : value_expression_primary
- ;
-
-reference_value_expression
- options {k=1;}
- : value_expression_primary
- ;
-
-/*
-==============================================================================================
- 6.26 numeric_value_expression (p240)
-
- Specify a numeric value.
-==============================================================================================
-*/
-
-numeric_value_expression
- options {k=1;}
- : term ((Plus_Sign|Minus_Sign)^ term)*
- ;
-
-term
- options {k=1;}
- : factor ((Asterisk|Slash|Percent)^ factor)*
- ;
-
-factor
- options {k=1;}
- : (sign)? numeric_primary
- ;
-
-numeric_primary
- options{k=1;}
- : value_expression_primary
- ;
-
-array
- : Left_Paren literal (Comma literal )* Right_Paren -> literal+
- ;
-
-/*
-==============================================================================================
- 6.28 string_value_expression (p251)
-
- Specify a character string value or a binary string value.
- TODO:
- * collate_clause
-==============================================================================================
-*/
-
-string_value_expression
- options{k=1;}
- : character_value_expression; // | blob_value_expression ;
-
-character_value_expression
- options{k=1;}
- : character_factor ( Concatenation_Operator character_factor )*;
-
-character_factor
- options{k=1;}
- : character_primary
- ;
-
-character_primary
- options{k=1;}
- : value_expression_primary
- ;
-
-/*
-==============================================================================================
- 6.3 value expression primary
-
-==============================================================================================
-*/
-
-value_expression_primary
- : parenthesized_value_expression
- | nonparenthesized_value_expression_primary
- ;
-
-parenthesized_value_expression
- options{k=1;}
- : Left_Paren! value_expression Right_Paren!
- ;
-
-/*
-==============================================================================================
- 6.34 boolean_value_expression (p277)
- Progress: Completed
-==============================================================================================
-*/
-
-boolean_value_expression
- options{k=1;}
- : boolean_term (OR^ boolean_term)*
- ;
-
-boolean_term
- options{k=1;}
- : boolean_factor (AND^ boolean_factor)*
- ;
-
-boolean_factor
- : boolean_test
- | NOT boolean_test -> ^(NOT boolean_test)
- ;
-
-boolean_test
- : boolean_primary is_clause?
- ;
-
-is_clause
- : IS NOT? t=truth_value -> ^(IS NOT? $t)
- ;
-
-truth_value
- : TRUE | FALSE | UNKNOWN
- ;
-
-boolean_primary
- options {k=1;}
- : predicate
- | boolean_predicand
- ;
-
-boolean_predicand
- options {k=1;}
- : parenthesized_boolean_value_expression
- | nonparenthesized_value_expression_primary
- ;
-
-parenthesized_boolean_value_expression
- options {k=1;}
- : Left_Paren! boolean_value_expression Right_Paren!
- ;
-
-nonparenthesized_value_expression_primary
- : fieldName
- | unsigned_value_specification
- | q=scalar_subquery -> ^(SUBQUERY $q)
- | case_expression
- | funcCall
- | NULL
- ;
-
-
-predicate
- options {k=1;}
- : comparison_predicate
- | in_predicate
- | like_predicate
- | null_predicate
- ;
-
-in_predicate
- : numeric_value_expression NOT? IN array -> ^(IN numeric_value_expression array NOT?)
- ;
-
-like_predicate
- : f=fieldName NOT? LIKE s=Character_String_Literal -> ^(LIKE NOT? $f $s)
- ;
-
-null_predicate
- : f=numeric_value_expression IS (n=NOT)? NULL -> ^(IS $f NULL $n?)
- ;
-
-/*
-==============================================================================================
- 6.4 <value specification> and <target specification> (p176)
-==============================================================================================
-*/
-
-value_specification
- options{k=1;}
- : literal
- | general_value_specification
- ;
-
-unsigned_value_specification
- options{k=1;}
- : unsigned_literal
- | general_value_specification ;
-
-general_value_specification
- : identifier_chain
- ;
-
-/*
-==============================================================================================
- 6.11 case_expression (p197)
-
- Progress: Almost done
- TODO:
- * when_operand
- * overlaps_predicate_part_1
-==============================================================================================
-*/
-
-case_expression
- : case_specification
- ;
-
-case_abbreviation
- : NULLIF Left_Paren value_expression Comma value_expression Right_Paren
- | COALESCE Left_Paren value_expression ( Comma value_expression )+ Right_Paren
- ;
-
-case_specification
- : simple_case
- | searched_case
- ;
-
-simple_case
- : CASE case_operand ( simple_when_clause )+ ( else_clause )? END
- ;
-
-searched_case
- : CASE^ (searched_when_clause)+ (else_clause)? END!
- ;
-
-simple_when_clause : WHEN when_operand THEN result ;
-
-searched_when_clause
- : WHEN c=search_condition THEN r=result -> ^(WHEN $c $r)
- ;
-
-else_clause
- : ELSE r=result -> ^(ELSE $r)
- ;
-
-case_operand
- options {k=1;}
- : row_value_predicand
-//| overlaps_predicate_part_1
- ;
-
-when_operand
- options {k=1;}
- : row_value_predicand
- ;
-
-result
- : result_expression | NULL
- ;
-
-result_expression : value_expression;
-
-/*
-==============================================================================================
- 7 Query expressions
- 7.1 <row value constructor> (p293)
-
- Specify a value or list of values to be constructed into a row or partial row.
-
- TODO
- * explicit_row_value_constructor
- * Others
-==============================================================================================
-*/
-
-row_value_constructor :
- common_value_expression
- | boolean_value_expression
-// | explicit_row_value_constructor
- ;
-
-row_value_constructor_predicand
- options {k=1;}
- : common_value_expression
- | boolean_predicand
-// | explicit_row_value_constructor
- ;
-
-/*
-==============================================================================================
- 7.15 <subquery> (p368)
-
- Specify a scalar value, a row, or a table derived from a query_expression .
-==============================================================================================
-*/
-
-scalar_subquery
- options {k=1;}
- : subquery
- ;
-
-row_subquery
- options {k=1;}
- : subquery
- ;
-
-table_subquery
- : subquery
- ;
-
-subquery
- options {k=1;}
- : Left_Paren! query_expression Right_Paren!
- ;
-
-/*
-==============================================================================================
- 7.2 row_value_expression (p296)
-
- Specify a row value.
-
- TODO
- * explicit_row_value_constructor
-==============================================================================================
-*/
-
-row_value_expression
- options {k=1;}
- : row_value_special_case
- //| explicit_row_value_constructor
- ;
-
-table_row_value_expression
- options {k=1;}
- : row_value_special_case
- | row_value_constructor
- ;
-
-contextually_typed_row_value_expression
- options {k=1;}
- : row_value_special_case
-// | contextually_typed_row_value_constructor
- ;
-
-row_value_predicand
- options {k=1;}
- : row_value_constructor_predicand
- | row_value_special_case
- ;
-
-row_value_special_case
- options {k=1;}
- : nonparenthesized_value_expression_primary
- ;
-
-/*
-==============================================================================================
- 8.2 <comparison predicate> (p373)
-
- Progress: completed
-==============================================================================================
-*/
-
-comparison_predicate
- options{k=1;}
- : l=row_value_predicand c=comp_op r=row_value_predicand -> ^($c $l $r)
- ;
-
-comp_op
- : Equals_Operator
- | Not_Equals_Operator
- | Less_Than_Operator
- | Less_Or_Equals_Operator
- | Greater_Than_Operator
- | Greater_Or_Equals_Operator
- ;
-
-/*
-==============================================================================================
- The Quote symbol rule consists of two immediately adjacent Quote marks with no spaces.
- As usual, this would be best handled in the lexical analyzer, not in the grammar.
-==============================================================================================
-*/
-
-quote_symbol : Quote Quote;
-sign : Plus_Sign | Minus_Sign;
-
-datetime_literal
- : date_literal | time_literal | timestamp_literal
- ;
-date_literal
- : DATE Quote years_value Minus_Sign months_value Minus_Sign days_value Quote
- ;
-time_literal
- : TIME Quote hours_value Colon minutes_value Colon seconds_value
- ( ( Plus_Sign | Minus_Sign ) hours_value Colon minutes_value )? Quote
- ;
-timestamp_literal
- : TIMESTAMP Quote years_value Minus_Sign months_value Minus_Sign days_value
- Space hours_value Colon minutes_value Colon seconds_value
- ( ( Plus_Sign | Minus_Sign ) hours_value Colon minutes_value )?
- Quote
- ;
-interval_literal
- : INTERVAL
- Quote ( Plus_Sign | Minus_Sign )? ( year_month_literal | day_time_literal ) Quote
- ;
-
-year_month_literal : years_value | years_value Minus_Sign months_value ;
-day_time_literal : day_time_interval | time_interval ;
-day_time_interval
- : DAYS days_value Space hours_value ( Colon minutes_value ( Colon seconds_value )? )?
- ;
-time_interval : HOURS hours_value ( Colon minutes_value ( Colon seconds_value )? )?;
-
-years_value : Unsigned_Integer ;
-months_value : Unsigned_Integer ;
-days_value : Unsigned_Integer ;
-hours_value : Unsigned_Integer ;
-minutes_value : Unsigned_Integer ;
-seconds_value : Unsigned_Integer ( Period ( Unsigned_Integer )? )?;
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/00c3ee2b/tajo-frontend/tajo-frontend-sql/src/main/java/org/apache/tajo/frontend/sql/QueryBlock.java
----------------------------------------------------------------------
diff --git a/tajo-frontend/tajo-frontend-sql/src/main/java/org/apache/tajo/frontend/sql/QueryBlock.java b/tajo-frontend/tajo-frontend-sql/src/main/java/org/apache/tajo/frontend/sql/QueryBlock.java
deleted file mode 100644
index 0f2042d..0000000
--- a/tajo-frontend/tajo-frontend-sql/src/main/java/org/apache/tajo/frontend/sql/QueryBlock.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.tajo.frontend.sql;
-
-import org.apache.tajo.algebra.*;
-
-public class QueryBlock {
- private String relName;
-
- /* projection */
- private Projection projection;
- /* distinct or all? */
- private boolean distinct = false;
- /* from clause or join clause */
- private Expr tableExpression = null;
- /* where clause */
- private Expr searchCondition = null;
- /* if true, there is at least grouping field. */
- private Aggregation aggregation = null;
- /* having condition */
- private Expr havingCondition = null;
- /* keys for ordering */
- private Sort sort = null;
- /* limit clause */
- private Limit limit = null;
-
- public QueryBlock() {
- }
-
- public void setProjection(Projection projection) {
- this.projection = projection;
- }
-
- public boolean hasTableExpression() {
- return this.tableExpression != null;
- }
-
- public Expr getTableExpression() {
- return this.tableExpression;
- }
-
- public void setTableExpression(Expr fromClause) {
- this.tableExpression = fromClause;
- }
-
- public boolean hasSearchCondition() {
- return searchCondition != null;
- }
-
- public Expr getSearchCondition() {
- return this.searchCondition;
- }
-
- public void setSearchCondition(Expr expr) {
- this.searchCondition = expr;
- }
-
- public boolean hasAggregation() {
- return this.aggregation != null;
- }
-
- public Aggregation getAggregation() {
- return this.aggregation;
- }
-
- public void setAggregation(Aggregation groupby) {
- this.aggregation = groupby;
- }
-
- public boolean hasHavingCondition(Expr expr) {
- return havingCondition != null;
- }
-
- public Expr getHavingCondition() {
- return havingCondition;
- }
-
- public void setHavingCondition(Expr expr) {
- havingCondition = expr;
- }
-
- public boolean hasSort() {
- return sort != null;
- }
-
- public Sort getSort() {
- return sort;
- }
-
- public void setSort(Sort sort) {
- this.sort = sort;
- }
-
- public boolean hasLimit() {
- return limit != null;
- }
-
- public Limit getLimit() {
- return this.limit;
- }
-
- public void setLimit(Limit limit) {
- this.limit = limit;
- }
-
- public Projection getProjection() {
- return this.projection;
- }
-
- public boolean isDistinct() {
- return this.distinct;
- }
-
- public void setDistinct() {
- this.distinct = true;
- }
-}