Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4688118DE5 for ; Sun, 10 Jan 2016 17:06:18 +0000 (UTC) Received: (qmail 43916 invoked by uid 500); 10 Jan 2016 17:06:18 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 43776 invoked by uid 500); 10 Jan 2016 17:06:18 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 43761 invoked by uid 99); 10 Jan 2016 17:06:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jan 2016 17:06:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AFC15DFFAE; Sun, 10 Jan 2016 17:06:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hashutosh@apache.org To: commits@hive.apache.org Date: Sun, 10 Jan 2016 17:06:18 -0000 Message-Id: <4467410122554e8babb36acd4e16781e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] hive git commit: HIVE-12590 : Repeated UDAFs with literals can produce incorrect result (Ashutosh Chauhan via John Pullokkaran) HIVE-12590 : Repeated UDAFs with literals can produce incorrect result (Ashutosh Chauhan via John Pullokkaran) Signed-off-by: Ashutosh Chauhan Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/54858565 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/54858565 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/54858565 Branch: refs/heads/branch-2.0 Commit: 5485856528bfe12aa4f2822964c5f8986620305a Parents: a9ae63b Author: Ashutosh Chauhan Authored: Wed Dec 16 21:00:21 2015 -0800 Committer: Ashutosh Chauhan Committed: Sun Jan 10 09:06:00 2016 -0800 ---------------------------------------------------------------------- .../apache/hadoop/hive/ql/parse/ASTNode.java | 27 +- .../hadoop/hive/ql/parse/CalcitePlanner.java | 2 +- .../hadoop/hive/ql/parse/RowResolver.java | 4 +- .../hadoop/hive/ql/parse/SemanticAnalyzer.java | 16 +- .../hive/ql/parse/TypeCheckProcFactory.java | 4 +- .../apache/hadoop/hive/ql/parse/TestIUD.java | 254 +++++++++---------- .../hadoop/hive/ql/parse/TestQBSubQuery.java | 66 +++-- .../TestSQL11ReservedKeyWordsPositive.java | 152 +++++------ .../positive/TestTransactionStatement.java | 31 ++- .../clientpositive/groupby_duplicate_key.q | 4 + .../join_cond_unqual_ambiguous_vc.q.out | 2 +- .../clientpositive/case_sensitivity.q.out | 2 +- .../results/clientpositive/constant_prop.q.out | 2 +- .../clientpositive/groupby_duplicate_key.q.out | 71 ++++++ 14 files changed, 356 insertions(+), 281 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java index b96e2eb..8400ee8 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java @@ -32,7 +32,7 @@ import org.apache.hadoop.hive.ql.lib.Node; */ public class ASTNode extends CommonTree implements Node,Serializable { private static final long serialVersionUID = 1L; - private transient StringBuffer astStr; + private transient StringBuilder astStr; private transient ASTNodeOrigin origin; private transient int startIndx = -1; private transient int endIndx = -1; @@ -133,10 +133,11 @@ public class ASTNode extends CommonTree implements Node,Serializable { return sb; } - private ASTNode getRootNodeWithValidASTStr (boolean useMemoizedRoot) { - if (useMemoizedRoot && rootNode != null && rootNode.parent == null && + private void getRootNodeWithValidASTStr () { + + if (rootNode != null && rootNode.parent == null && rootNode.hasValidMemoizedString()) { - return rootNode; + return; } ASTNode retNode = this; while (retNode.parent != null) { @@ -144,11 +145,11 @@ public class ASTNode extends CommonTree implements Node,Serializable { } rootNode=retNode; if (!rootNode.isValidASTStr) { - rootNode.astStr = new StringBuffer(); + rootNode.astStr = new StringBuilder(); rootNode.toStringTree(rootNode); rootNode.isValidASTStr = true; } - return retNode; + return; } private boolean hasValidMemoizedString() { @@ -174,7 +175,7 @@ public class ASTNode extends CommonTree implements Node,Serializable { private void addtoMemoizedString(String string) { if (astStr == null) { - astStr = new StringBuffer(); + astStr = new StringBuilder(); } astStr.append(string); } @@ -227,7 +228,7 @@ public class ASTNode extends CommonTree implements Node,Serializable { // The root might have changed because of tree modifications. // Compute the new root for this tree and set the astStr. - getRootNodeWithValidASTStr(true); + getRootNodeWithValidASTStr(); // If rootNotModified is false, then startIndx and endIndx will be stale. if (startIndx >= 0 && endIndx <= rootNode.getMemoizedStringLen()) { @@ -240,14 +241,18 @@ public class ASTNode extends CommonTree implements Node,Serializable { this.rootNode = rootNode; startIndx = rootNode.getMemoizedStringLen(); // Leaf node + String str; if ( children==null || children.size()==0 ) { - rootNode.addtoMemoizedString(this.toString()); + str = this.toString(); + rootNode.addtoMemoizedString(this.getType() != HiveParser.StringLiteral ? str.toLowerCase() : str); endIndx = rootNode.getMemoizedStringLen(); - return this.toString(); + return this.getType() != HiveParser.StringLiteral ? str.toLowerCase() : str; } + if ( !isNil() ) { rootNode.addtoMemoizedString("("); - rootNode.addtoMemoizedString(this.toString()); + str = this.toString(); + rootNode.addtoMemoizedString((this.getType() == HiveParser.StringLiteral || null == str) ? str : str.toLowerCase()); rootNode.addtoMemoizedString(" "); } for (int i = 0; children!=null && i < children.size(); i++) { http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java index 23f6869..686c043 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java @@ -1602,7 +1602,7 @@ public class CalcitePlanner extends SemanticAnalyzer { VirtualColumn vc = vcs.next(); colInfo = new ColumnInfo(vc.getName(), vc.getTypeInfo(), tableAlias, true, vc.getIsHidden()); - rr.put(tableAlias, vc.getName(), colInfo); + rr.put(tableAlias, vc.getName().toLowerCase(), colInfo); cInfoLst.add(colInfo); virtualCols.add(vc); } http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java index 891b1f7..0bd036f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java @@ -112,7 +112,6 @@ public class RowResolver implements Serializable{ if (tab_alias != null) { tab_alias = tab_alias.toLowerCase(); } - col_alias = col_alias.toLowerCase(); /* * allow multiple mappings to the same ColumnInfo. @@ -169,7 +168,6 @@ public class RowResolver implements Serializable{ * @throws SemanticException */ public ColumnInfo get(String tab_alias, String col_alias) throws SemanticException { - col_alias = col_alias.toLowerCase(); ColumnInfo ret = null; if (tab_alias != null) { @@ -476,4 +474,4 @@ public class RowResolver implements Serializable{ resolver.isExprResolver = isExprResolver; return resolver; } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 197e6da..4c498f3 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -541,7 +541,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { if(containsLeadLagUDF(expressionTree)) { throw new SemanticException(ErrorMsg.MISSING_OVER_CLAUSE.getMsg(functionName)); } - aggregations.put(expressionTree.toStringTree().toLowerCase(), expressionTree); + aggregations.put(expressionTree.toStringTree(), expressionTree); FunctionInfo fi = FunctionRegistry.getFunctionInfo(functionName); if (!fi.isNative()) { unparseTranslator.addIdentifierTranslation((ASTNode) expressionTree @@ -3529,7 +3529,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { (selExpr.getChildCount() == 3 && selExpr.getChild(2).getType() == HiveParser.TOK_WINDOWSPEC)) { // return zz for "xx + yy AS zz" - colAlias = unescapeIdentifier(selExpr.getChild(1).getText()); + colAlias = unescapeIdentifier(selExpr.getChild(1).getText().toLowerCase()); colRef[0] = tabAlias; colRef[1] = colAlias; return colRef; @@ -3538,7 +3538,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { ASTNode root = (ASTNode) selExpr.getChild(0); if (root.getType() == HiveParser.TOK_TABLE_OR_COL) { colAlias = - BaseSemanticAnalyzer.unescapeIdentifier(root.getChild(0).getText()); + BaseSemanticAnalyzer.unescapeIdentifier(root.getChild(0).getText().toLowerCase()); colRef[0] = tabAlias; colRef[1] = colAlias; return colRef; @@ -3556,7 +3556,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { // Return zz for "xx.zz" and "xx.yy.zz" ASTNode col = (ASTNode) root.getChild(1); if (col.getType() == HiveParser.Identifier) { - colAlias = unescapeIdentifier(col.getText()); + colAlias = unescapeIdentifier(col.getText().toLowerCase()); } } @@ -3566,7 +3566,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { String expr_flattened = root.toStringTree(); // remove all TOK tokens - String expr_no_tok = expr_flattened.replaceAll("TOK_\\S+", ""); + String expr_no_tok = expr_flattened.replaceAll("tok_\\S+", ""); // remove all non alphanumeric letters, replace whitespace spans with underscore String expr_formatted = expr_no_tok.replaceAll("\\W", " ").trim().replaceAll("\\s+", "_"); @@ -3704,7 +3704,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { ASTNode selExprChild = (ASTNode) selExpr.getChild(i); switch (selExprChild.getType()) { case HiveParser.Identifier: - udtfColAliases.add(unescapeIdentifier(selExprChild.getText())); + udtfColAliases.add(unescapeIdentifier(selExprChild.getText().toLowerCase())); unparseTranslator.addIdentifierTranslation(selExprChild); break; case HiveParser.TOK_TABALIAS: @@ -5380,7 +5380,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { if (!groupingSets.isEmpty()) { throw new SemanticException(ErrorMsg.HIVE_GROUPING_SETS_AGGR_NOMAPAGGR_MULTIGBY.getMsg()); } - + ASTNode whereExpr = parseInfo.getWhrForClause(dest); if (whereExpr != null) { @@ -9320,7 +9320,7 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer { List vcList = new ArrayList(); while (vcs.hasNext()) { VirtualColumn vc = vcs.next(); - rwsch.put(alias, vc.getName(), new ColumnInfo(vc.getName(), + rwsch.put(alias, vc.getName().toLowerCase(), new ColumnInfo(vc.getName(), vc.getTypeInfo(), alias, true, vc.getIsHidden())); vcList.add(vc); } http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java index 9d8b352..598520c 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java @@ -378,7 +378,7 @@ public class TypeCheckProcFactory { default: // HiveParser.identifier | HiveParse.KW_IF | HiveParse.KW_LEFT | // HiveParse.KW_RIGHT - str = BaseSemanticAnalyzer.unescapeIdentifier(expr.getText()); + str = BaseSemanticAnalyzer.unescapeIdentifier(expr.getText().toLowerCase()); break; } return new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, str); @@ -818,7 +818,7 @@ public class TypeCheckProcFactory { ((SettableUDF)genericUDF).setTypeInfo(typeInfo); } } - + List childrenList = new ArrayList(children.length); childrenList.addAll(Arrays.asList(children)); http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java index 9d4457c..3d2e648 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestIUD.java @@ -55,100 +55,100 @@ public class TestIUD { } return (ASTNode) nd.getChild(0); } - + @Test public void testDeleteNoWhere() throws ParseException { ASTNode ast = parse("DELETE FROM src"); - Assert.assertEquals("AST doesn't match", - "(TOK_DELETE_FROM " + - "(TOK_TABNAME src))", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", + "(tok_delete_from " + + "(tok_tabname src))", ast.toStringTree()); } @Test public void testDeleteWithWhere() throws ParseException { ASTNode ast = parse("DELETE FROM src WHERE key IS NOT NULL AND src.value < 0"); - Assert.assertEquals("AST doesn't match", - "(TOK_DELETE_FROM " + - "(TOK_TABNAME src) " + - "(TOK_WHERE " + - "(AND " + - "(TOK_FUNCTION TOK_ISNOTNULL (TOK_TABLE_OR_COL key)) " + - "(< (. (TOK_TABLE_OR_COL src) value) 0))))", + Assert.assertEquals("AST doesn't match", + "(tok_delete_from " + + "(tok_tabname src) " + + "(tok_where " + + "(and " + + "(tok_function tok_isnotnull (tok_table_or_col key)) " + + "(< (. (tok_table_or_col src) value) 0))))", ast.toStringTree()); } @Test public void testUpdateNoWhereSingleSet() throws ParseException { ASTNode ast = parse("UPDATE src set key = 3"); Assert.assertEquals("AST doesn't match", - "(TOK_UPDATE_TABLE " + - "(TOK_TABNAME src) " + - "(TOK_SET_COLUMNS_CLAUSE " + + "(tok_update_table " + + "(tok_tabname src) " + + "(tok_set_columns_clause " + "(= " + - "(TOK_TABLE_OR_COL key) 3)))", + "(tok_table_or_col key) 3)))", ast.toStringTree()); } @Test public void testUpdateNoWhereMultiSet() throws ParseException { ASTNode ast = parse("UPDATE src set key = 3, value = 8"); - Assert.assertEquals("AST doesn't match", - "(TOK_UPDATE_TABLE " + - "(TOK_TABNAME src) " + - "(TOK_SET_COLUMNS_CLAUSE " + + Assert.assertEquals("AST doesn't match", + "(tok_update_table " + + "(tok_tabname src) " + + "(tok_set_columns_clause " + "(= " + - "(TOK_TABLE_OR_COL key) 3) " + + "(tok_table_or_col key) 3) " + "(= " + - "(TOK_TABLE_OR_COL value) 8)))", + "(tok_table_or_col value) 8)))", ast.toStringTree()); } @Test public void testUpdateWithWhereSingleSet() throws ParseException { ASTNode ast = parse("UPDATE src SET key = 3 WHERE value IS NULL"); Assert.assertEquals("AST doesn't match", - "(TOK_UPDATE_TABLE " + - "(TOK_TABNAME src) " + - "(TOK_SET_COLUMNS_CLAUSE " + + "(tok_update_table " + + "(tok_tabname src) " + + "(tok_set_columns_clause " + "(= " + - "(TOK_TABLE_OR_COL key) 3)) " + - "(TOK_WHERE (TOK_FUNCTION TOK_ISNULL (TOK_TABLE_OR_COL value))))", + "(tok_table_or_col key) 3)) " + + "(tok_where (tok_function tok_isnull (tok_table_or_col value))))", ast.toStringTree()); } @Test public void testUpdateWithWhereSingleSetExpr() throws ParseException { ASTNode ast = parse("UPDATE src SET key = -3+(5*9)%8, val = cast(6.1 + c as INT), d = d - 1 WHERE value IS NULL"); Assert.assertEquals("AST doesn't match", - "(TOK_UPDATE_TABLE (TOK_TABNAME src) " + - "(TOK_SET_COLUMNS_CLAUSE " + - "(= (TOK_TABLE_OR_COL key) (+ (- 3) (% (* 5 9) 8))) " + - "(= (TOK_TABLE_OR_COL val) (TOK_FUNCTION TOK_INT (+ 6.1 (TOK_TABLE_OR_COL c)))) " + - "(= (TOK_TABLE_OR_COL d) (- (TOK_TABLE_OR_COL d) 1))) " + - "(TOK_WHERE (TOK_FUNCTION TOK_ISNULL (TOK_TABLE_OR_COL value))))", + "(tok_update_table (tok_tabname src) " + + "(tok_set_columns_clause " + + "(= (tok_table_or_col key) (+ (- 3) (% (* 5 9) 8))) " + + "(= (tok_table_or_col val) (tok_function tok_int (+ 6.1 (tok_table_or_col c)))) " + + "(= (tok_table_or_col d) (- (tok_table_or_col d) 1))) " + + "(tok_where (tok_function tok_isnull (tok_table_or_col value))))", ast.toStringTree()); } @Test public void testUpdateWithWhereMultiSet() throws ParseException { ASTNode ast = parse("UPDATE src SET key = 3, value = 8 WHERE VALUE = 1230997"); - Assert.assertEquals("AST doesn't match", - "(TOK_UPDATE_TABLE " + - "(TOK_TABNAME src) " + - "(TOK_SET_COLUMNS_CLAUSE " + + Assert.assertEquals("AST doesn't match", + "(tok_update_table " + + "(tok_tabname src) " + + "(tok_set_columns_clause " + "(= " + - "(TOK_TABLE_OR_COL key) 3) " + + "(tok_table_or_col key) 3) " + "(= " + - "(TOK_TABLE_OR_COL value) 8)) " + - "(TOK_WHERE (= (TOK_TABLE_OR_COL VALUE) 1230997)))", + "(tok_table_or_col value) 8)) " + + "(tok_where (= (tok_table_or_col value) 1230997)))", ast.toStringTree()); } @Test public void testStandardInsertIntoTable() throws ParseException { ASTNode ast = parse("INSERT into TABLE page_view SELECT pvs.viewTime, pvs.userid from page_view_stg pvs where pvs.userid is null"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_TABREF (TOK_TABNAME page_view_stg) pvs)) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME page_view))) " + - "(TOK_SELECT " + - "(TOK_SELEXPR (. (TOK_TABLE_OR_COL pvs) viewTime)) " + - "(TOK_SELEXPR (. (TOK_TABLE_OR_COL pvs) userid))) " + - "(TOK_WHERE (TOK_FUNCTION TOK_ISNULL (. (TOK_TABLE_OR_COL pvs) userid)))))", + "(tok_query " + + "(tok_from " + + "(tok_tabref (tok_tabname page_view_stg) pvs)) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname page_view))) " + + "(tok_select " + + "(tok_selexpr (. (tok_table_or_col pvs) viewtime)) " + + "(tok_selexpr (. (tok_table_or_col pvs) userid))) " + + "(tok_where (tok_function tok_isnull (. (tok_table_or_col pvs) userid)))))", ast.toStringTree()); } @Test @@ -163,55 +163,55 @@ public class TestIUD { } @Test public void testSelectStarFromVirtTable1Row() throws ParseException { - ASTNode ast = parse("select * from (values (3,4)) as VC(a,b)"); + ASTNode ast = parse("select * from (values (3,4)) as vc(a,b)"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF (TOK_TABNAME VC) (TOK_COL_NAME a b)) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW 3 4)))) " + - "(TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref (tok_tabname vc) (tok_col_name a b)) " + + "(tok_values_table (tok_value_row 3 4)))) " + + "(tok_insert (tok_destination (tok_dir tok_tmp_file)) (tok_select (tok_selexpr tok_allcolref))))", ast.toStringTree()); } @Test public void testSelectStarFromVirtTable2Row() throws ParseException { - ASTNode ast = parse("select * from (values (1,2),(3,4)) as VC(a,b)"); + ASTNode ast = parse("select * from (values (1,2),(3,4)) as vc(a,b)"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF (TOK_TABNAME VC) (TOK_COL_NAME a b)) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW 1 2) (TOK_VALUE_ROW 3 4)))) " + - "(TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref (tok_tabname vc) (tok_col_name a b)) " + + "(tok_values_table (tok_value_row 1 2) (tok_value_row 3 4)))) " + + "(tok_insert (tok_destination (tok_dir tok_tmp_file)) (tok_select (tok_selexpr tok_allcolref))))", ast.toStringTree()); } @Test public void testSelectStarFromVirtTable2RowNamedProjections() throws ParseException { - ASTNode ast = parse("select a as c, b as d from (values (1,2),(3,4)) as VC(a,b)"); + ASTNode ast = parse("select a as c, b as d from (values (1,2),(3,4)) as vc(a,b)"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF (TOK_TABNAME VC) (TOK_COL_NAME a b)) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW 1 2) (TOK_VALUE_ROW 3 4)))) " + - "(TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) " + - "(TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL a) c) (TOK_SELEXPR (TOK_TABLE_OR_COL b) d))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref (tok_tabname vc) (tok_col_name a b)) " + + "(tok_values_table (tok_value_row 1 2) (tok_value_row 3 4)))) " + + "(tok_insert (tok_destination (tok_dir tok_tmp_file)) " + + "(tok_select (tok_selexpr (tok_table_or_col a) c) (tok_selexpr (tok_table_or_col b) d))))", ast.toStringTree()); } @Test public void testInsertIntoTableAsSelectFromNamedVirtTable() throws ParseException { - ASTNode ast = parse("insert into page_view select a,b as c from (values (1,2),(3,4)) as VC(a,b) where b = 9"); + ASTNode ast = parse("insert into page_view select a,b as c from (values (1,2),(3,4)) as vc(a,b) where b = 9"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF (TOK_TABNAME VC) (TOK_COL_NAME a b)) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW 1 2) (TOK_VALUE_ROW 3 4)))) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME page_view))) " + - "(TOK_SELECT " + - "(TOK_SELEXPR (TOK_TABLE_OR_COL a)) " + - "(TOK_SELEXPR (TOK_TABLE_OR_COL b) c)) " + - "(TOK_WHERE (= (TOK_TABLE_OR_COL b) 9))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref (tok_tabname vc) (tok_col_name a b)) " + + "(tok_values_table (tok_value_row 1 2) (tok_value_row 3 4)))) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname page_view))) " + + "(tok_select " + + "(tok_selexpr (tok_table_or_col a)) " + + "(tok_selexpr (tok_table_or_col b) c)) " + + "(tok_where (= (tok_table_or_col b) 9))))", ast.toStringTree()); } /** @@ -220,31 +220,31 @@ public class TestIUD { */ @Test public void testInsertIntoTableAsSelectFromNamedVirtTableNamedCol() throws ParseException { - ASTNode ast = parse("insert into page_view(c1,c2) select a,b as c from (values (1,2),(3,4)) as VC(a,b) where b = 9"); + ASTNode ast = parse("insert into page_view(c1,c2) select a,b as c from (values (1,2),(3,4)) as vc(a,b) where b = 9"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF (TOK_TABNAME VC) (TOK_COL_NAME a b)) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW 1 2) (TOK_VALUE_ROW 3 4)))) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME page_view)) (TOK_TABCOLNAME c1 c2)) " + - "(TOK_SELECT " + - "(TOK_SELEXPR (TOK_TABLE_OR_COL a)) " + - "(TOK_SELEXPR (TOK_TABLE_OR_COL b) c)) " + - "(TOK_WHERE (= (TOK_TABLE_OR_COL b) 9))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref (tok_tabname vc) (tok_col_name a b)) " + + "(tok_values_table (tok_value_row 1 2) (tok_value_row 3 4)))) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname page_view)) (tok_tabcolname c1 c2)) " + + "(tok_select " + + "(tok_selexpr (tok_table_or_col a)) " + + "(tok_selexpr (tok_table_or_col b) c)) " + + "(tok_where (= (tok_table_or_col b) 9))))", ast.toStringTree()); } @Test public void testInsertIntoTableFromAnonymousTable1Row() throws ParseException { ASTNode ast = parse("insert into page_view values(1,2)"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF TOK_ANONYMOUS) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW 1 2)))) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME page_view))) " + - "(TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref tok_anonymous) " + + "(tok_values_table (tok_value_row 1 2)))) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname page_view))) " + + "(tok_select (tok_selexpr tok_allcolref))))", ast.toStringTree()); } /** @@ -255,20 +255,20 @@ public class TestIUD { public void testInsertIntoTableFromAnonymousTable1RowNamedCol() throws ParseException { ASTNode ast = parse("insert into page_view(a,b) values(1,2)"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF TOK_ANONYMOUS) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW 1 2))" + + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref tok_anonymous) " + + "(tok_values_table (tok_value_row 1 2))" + ")" + ") " + - "(TOK_INSERT " + - "(TOK_INSERT_INTO " + - "(TOK_TAB (TOK_TABNAME page_view)) " + - "(TOK_TABCOLNAME a b)" +//this is "extra" piece we get vs previous query + "(tok_insert " + + "(tok_insert_into " + + "(tok_tab (tok_tabname page_view)) " + + "(tok_tabcolname a b)" +//this is "extra" piece we get vs previous query ") " + - "(TOK_SELECT " + - "(TOK_SELEXPR TOK_ALLCOLREF)" + + "(tok_select " + + "(tok_selexpr tok_allcolref)" + ")" + ")" + ")", ast.toStringTree()); @@ -277,31 +277,31 @@ public class TestIUD { public void testInsertIntoTableFromAnonymousTable() throws ParseException { ASTNode ast = parse("insert into table page_view values(-1,2),(3,+4)"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF TOK_ANONYMOUS) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW (- 1) 2) (TOK_VALUE_ROW 3 (+ 4))))) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME page_view))) " + - "(TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref tok_anonymous) " + + "(tok_values_table (tok_value_row (- 1) 2) (tok_value_row 3 (+ 4))))) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname page_view))) " + + "(tok_select (tok_selexpr tok_allcolref))))", ast.toStringTree()); - //same query as above less the "table" keyword KW_TABLE + //same query as above less the "table" keyword KW_table ast = parse("insert into page_view values(-1,2),(3,+4)"); Assert.assertEquals("AST doesn't match", - "(TOK_QUERY " + - "(TOK_FROM " + - "(TOK_VIRTUAL_TABLE " + - "(TOK_VIRTUAL_TABREF TOK_ANONYMOUS) " + - "(TOK_VALUES_TABLE (TOK_VALUE_ROW (- 1) 2) (TOK_VALUE_ROW 3 (+ 4))))) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME page_view))) " + - "(TOK_SELECT (TOK_SELEXPR TOK_ALLCOLREF))))", + "(tok_query " + + "(tok_from " + + "(tok_virtual_table " + + "(tok_virtual_tabref tok_anonymous) " + + "(tok_values_table (tok_value_row (- 1) 2) (tok_value_row 3 (+ 4))))) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname page_view))) " + + "(tok_select (tok_selexpr tok_allcolref))))", ast.toStringTree()); } @Test public void testMultiInsert() throws ParseException { ASTNode ast = parse("from S insert into T1 select a, b insert into T2 select c, d"); - Assert.assertEquals("AST doesn't match", "(TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME S))) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME T1))) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL a)) (TOK_SELEXPR (TOK_TABLE_OR_COL b)))) " + - "(TOK_INSERT (TOK_INSERT_INTO (TOK_TAB (TOK_TABNAME T2))) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL c)) (TOK_SELEXPR (TOK_TABLE_OR_COL d)))))", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", "(tok_query (tok_from (tok_tabref (tok_tabname s))) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname t1))) (tok_select (tok_selexpr (tok_table_or_col a)) (tok_selexpr (tok_table_or_col b)))) " + + "(tok_insert (tok_insert_into (tok_tab (tok_tabname t2))) (tok_select (tok_selexpr (tok_table_or_col c)) (tok_selexpr (tok_table_or_col d)))))", ast.toStringTree()); } } http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/org/apache/hadoop/hive/ql/parse/TestQBSubQuery.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestQBSubQuery.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestQBSubQuery.java index 77ff79a..f6f0abb 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestQBSubQuery.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestQBSubQuery.java @@ -21,25 +21,24 @@ package org.apache.hadoop.hive.ql.parse; import java.util.ArrayList; import java.util.List; -import junit.framework.Assert; - import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.ql.session.SessionState; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; public class TestQBSubQuery { static HiveConf conf; - + private static String IN_QUERY = " select * " + "from src " + "where src.key in (select key from src s1 where s1.key > '9' and s1.value > '9') "; - + private static String IN_QUERY2 = " select * " + "from src " + "where src.key in (select key from src s1 where s1.key > '9' and s1.value > '9') and value > '9'"; - + private static String QUERY3 = "select p_mfgr, min(p_size), rank() over(partition by p_mfgr) as r from part group by p_mfgr"; ParseDriver pd; @@ -61,73 +60,72 @@ public class TestQBSubQuery { ASTNode nd = pd.parse(query); return (ASTNode) nd.getChild(0); } - + @Test public void testExtractSubQueries() throws Exception { ASTNode ast = parse(IN_QUERY); ASTNode where = where(ast); List sqs = SubQueryUtils.findSubQueries((ASTNode) where.getChild(0)); - Assert.assertEquals(sqs.size(), 1); - + Assert.assertEquals(1,sqs.size()); + ASTNode sq = sqs.get(0); - Assert.assertEquals(sq.toStringTree(), - "(TOK_SUBQUERY_EXPR (TOK_SUBQUERY_OP in) (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME src) s1)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL key))) (TOK_WHERE (and (> (. (TOK_TABLE_OR_COL s1) key) '9') (> (. (TOK_TABLE_OR_COL s1) value) '9'))))) (. (TOK_TABLE_OR_COL src) key))" - ); + Assert.assertEquals("(tok_subquery_expr (tok_subquery_op in) (tok_query (tok_from (tok_tabref (tok_tabname src) s1)) (tok_insert (tok_destination (tok_dir tok_tmp_file)) (tok_select (tok_selexpr (tok_table_or_col key))) (tok_where (and (> (. (tok_table_or_col s1) key) '9') (> (. (tok_table_or_col s1) value) '9'))))) (. (tok_table_or_col src) key))" + ,sq.toStringTree()); } - + @Test public void testExtractConjuncts() throws Exception { ASTNode ast = parse(IN_QUERY); ASTNode where = where(ast); - List sqs = SubQueryUtils.findSubQueries((ASTNode) where.getChild(0)); + List sqs = SubQueryUtils.findSubQueries((ASTNode) where.getChild(0)); ASTNode sq = sqs.get(0); - + ASTNode sqWhere = where((ASTNode) sq.getChild(1)); - + List conjuncts = new ArrayList(); SubQueryUtils.extractConjuncts((ASTNode) sqWhere.getChild(0), conjuncts); - Assert.assertEquals(conjuncts.size(), 2); - - Assert.assertEquals(conjuncts.get(0).toStringTree(), "(> (. (TOK_TABLE_OR_COL s1) key) '9')"); - Assert.assertEquals(conjuncts.get(1).toStringTree(), "(> (. (TOK_TABLE_OR_COL s1) value) '9')"); + Assert.assertEquals(2, conjuncts.size()); + + Assert.assertEquals("(> (. (tok_table_or_col s1) key) '9')", conjuncts.get(0).toStringTree()); + Assert.assertEquals("(> (. (tok_table_or_col s1) value) '9')", conjuncts.get(1).toStringTree()); } - + @Test public void testRewriteOuterQueryWhere() throws Exception { ASTNode ast = parse(IN_QUERY); ASTNode where = where(ast); - List sqs = SubQueryUtils.findSubQueries((ASTNode) where.getChild(0)); + List sqs = SubQueryUtils.findSubQueries((ASTNode) where.getChild(0)); ASTNode sq = sqs.get(0); - + ASTNode newWhere = SubQueryUtils.rewriteParentQueryWhere((ASTNode) where.getChild(0), sq); - Assert.assertEquals(newWhere.toStringTree(), "(= 1 1)"); + Assert.assertEquals("(= 1 1)",newWhere.toStringTree()); } - + @Test public void testRewriteOuterQueryWhere2() throws Exception { ASTNode ast = parse(IN_QUERY2); ASTNode where = where(ast); - List sqs = SubQueryUtils.findSubQueries((ASTNode) where.getChild(0)); + List sqs = SubQueryUtils.findSubQueries((ASTNode) where.getChild(0)); ASTNode sq = sqs.get(0); - + ASTNode newWhere = SubQueryUtils.rewriteParentQueryWhere((ASTNode) where.getChild(0), sq); - Assert.assertEquals(newWhere.toStringTree(), "(> (TOK_TABLE_OR_COL value) '9')"); + Assert.assertEquals("(> (tok_table_or_col value) '9')",newWhere.toStringTree()); } - + @Test public void testCheckAggOrWindowing() throws Exception { ASTNode ast = parse(QUERY3); ASTNode select = select(ast); - - Assert.assertEquals(SubQueryUtils.checkAggOrWindowing((ASTNode) select.getChild(0)), 0); - Assert.assertEquals(SubQueryUtils.checkAggOrWindowing((ASTNode) select.getChild(1)), 1); - Assert.assertEquals(SubQueryUtils.checkAggOrWindowing((ASTNode) select.getChild(2)), 2); + + Assert.assertEquals(0, SubQueryUtils.checkAggOrWindowing((ASTNode) select.getChild(0))); + Assert.assertEquals(1, SubQueryUtils.checkAggOrWindowing((ASTNode) select.getChild(1))); + Assert.assertEquals(2, SubQueryUtils.checkAggOrWindowing((ASTNode) select.getChild(2))); } - + private ASTNode where(ASTNode qry) { return (ASTNode) qry.getChild(1).getChild(2); } - + private ASTNode select(ASTNode qry) { return (ASTNode) qry.getChild(1).getChild(1); } http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/org/apache/hadoop/hive/ql/parse/TestSQL11ReservedKeyWordsPositive.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestSQL11ReservedKeyWordsPositive.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestSQL11ReservedKeyWordsPositive.java index 2a68899..d0e6132 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestSQL11ReservedKeyWordsPositive.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestSQL11ReservedKeyWordsPositive.java @@ -65,7 +65,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME ALL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname all) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -75,7 +75,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME ALTER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname alter) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -85,7 +85,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME ARRAY) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname array) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -95,7 +95,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME AS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname as) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -105,7 +105,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME AUTHORIZATION) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname authorization) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -115,7 +115,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME BETWEEN) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname between) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -125,7 +125,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME BIGINT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname bigint) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -135,7 +135,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME BINARY) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname binary) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -145,7 +145,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME BOOLEAN) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname boolean) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -155,7 +155,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME BOTH) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname both) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -165,7 +165,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME BY) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname by) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -175,7 +175,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME CREATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname create) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -185,7 +185,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME CUBE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname cube) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -195,7 +195,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME CURRENT_DATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname current_date) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -205,7 +205,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME CURRENT_TIMESTAMP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname current_timestamp) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -215,7 +215,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME CURSOR) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname cursor) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -225,7 +225,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME DATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname date) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -235,7 +235,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME DECIMAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname decimal) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -245,7 +245,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME DELETE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname delete) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -255,7 +255,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME DESCRIBE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname describe) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -265,7 +265,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME DOUBLE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname double) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -275,7 +275,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME DROP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname drop) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -285,7 +285,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME EXISTS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname exists) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -295,7 +295,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME EXTERNAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname external) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -305,7 +305,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME FALSE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname false) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -315,7 +315,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME FETCH) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname fetch) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -325,7 +325,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME FLOAT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname float) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -335,7 +335,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME FOR) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname for) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -345,7 +345,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME FULL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname full) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -355,7 +355,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME GRANT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname grant) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -365,7 +365,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME GROUP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname group) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -375,7 +375,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME GROUPING) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname grouping) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -385,7 +385,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME IMPORT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname import) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -395,7 +395,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME IN) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname in) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -405,7 +405,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME INNER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname inner) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -415,7 +415,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME INSERT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname insert) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -425,7 +425,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME INT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname int) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -435,7 +435,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME INTERSECT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname intersect) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -445,7 +445,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME INTO) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname into) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -455,7 +455,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME IS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname is) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -465,7 +465,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME LATERAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname lateral) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -475,7 +475,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME LEFT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname left) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -485,7 +485,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME LIKE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname like) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -495,7 +495,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME LOCAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname local) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -505,7 +505,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME NONE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname none) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -515,7 +515,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME NULL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname null) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -525,7 +525,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME OF) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname of) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -535,7 +535,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME ORDER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname order) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -545,7 +545,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME OUT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname out) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -555,7 +555,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME OUTER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname outer) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -565,7 +565,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME PARTITION) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname partition) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -575,7 +575,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME PERCENT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname percent) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -585,7 +585,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME PROCEDURE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname procedure) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -595,7 +595,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME RANGE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname range) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -605,7 +605,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME READS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname reads) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -615,7 +615,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME REVOKE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname revoke) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -625,7 +625,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME RIGHT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname right) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -635,7 +635,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME ROLLUP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname rollup) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -645,7 +645,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME ROW) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname row) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -655,7 +655,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME ROWS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname rows) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -665,7 +665,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME SET) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname set) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -675,7 +675,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME SMALLINT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname smallint) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -685,7 +685,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME TABLE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname table) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -695,7 +695,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME TIMESTAMP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname timestamp) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -705,7 +705,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME TO) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname to) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -715,7 +715,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME TRIGGER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname trigger) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -725,7 +725,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME TRUE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname true) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -735,7 +735,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME TRUNCATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname truncate) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -745,7 +745,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME UNION) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname union) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -755,7 +755,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME UPDATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname update) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -765,7 +765,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME USER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname user) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -775,7 +775,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME USING) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname using) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -785,7 +785,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME VALUES) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname values) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -795,7 +795,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME WITH) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname with) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -806,7 +806,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME RLIKE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname rlike) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } @@ -816,7 +816,7 @@ public class TestSQL11ReservedKeyWordsPositive { Assert .assertEquals( "AST doesn't match", - "(TOK_CREATETABLE (TOK_TABNAME REGEXP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", + "(tok_createtable (tok_tabname regexp) tok_liketable (tok_tabcollist (tok_tabcol col tok_string)))", ast.toStringTree()); } } http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/org/apache/hadoop/hive/ql/parse/positive/TestTransactionStatement.java ---------------------------------------------------------------------- diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/positive/TestTransactionStatement.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/positive/TestTransactionStatement.java index b7f8263..4c8fabb 100644 --- a/ql/src/test/org/apache/hadoop/hive/ql/parse/positive/TestTransactionStatement.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/positive/TestTransactionStatement.java @@ -30,7 +30,6 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import java.io.File; import java.io.IOException; /** @@ -65,38 +64,38 @@ public class TestTransactionStatement { public void testTxnStart() throws ParseException { ASTNode ast = parse("START TRANSACTION"); Assert.assertEquals("AST doesn't match", - "TOK_START_TRANSACTION", ast.toStringTree()); - + "tok_start_transaction", ast.toStringTree()); + ast = parse("START TRANSACTION ISOLATION LEVEL SNAPSHOT"); Assert.assertEquals("AST doesn't match", - "(TOK_START_TRANSACTION (TOK_ISOLATION_LEVEL TOK_ISOLATION_SNAPSHOT))", ast.toStringTree()); - + "(tok_start_transaction (tok_isolation_level tok_isolation_snapshot))", ast.toStringTree()); + ast = parse("START TRANSACTION READ ONLY"); Assert.assertEquals("AST doesn't match", - "(TOK_START_TRANSACTION (TOK_TXN_ACCESS_MODE TOK_TXN_READ_ONLY))", ast.toStringTree()); - + "(tok_start_transaction (tok_txn_access_mode tok_txn_read_only))", ast.toStringTree()); + ast = parse("START TRANSACTION READ WRITE, ISOLATION LEVEL SNAPSHOT"); Assert.assertEquals("AST doesn't match", - "(TOK_START_TRANSACTION (TOK_TXN_ACCESS_MODE TOK_TXN_READ_WRITE) (TOK_ISOLATION_LEVEL TOK_ISOLATION_SNAPSHOT))", ast.toStringTree()); - + "(tok_start_transaction (tok_txn_access_mode tok_txn_read_write) (tok_isolation_level tok_isolation_snapshot))", ast.toStringTree()); + } @Test public void testTxnCommitRollback() throws ParseException { ASTNode ast = parse("COMMIT"); - Assert.assertEquals("AST doesn't match", "TOK_COMMIT", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", "tok_commit", ast.toStringTree()); ast = parse("COMMIT WORK"); - Assert.assertEquals("AST doesn't match", "TOK_COMMIT", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", "tok_commit", ast.toStringTree()); ast = parse("ROLLBACK"); - Assert.assertEquals("AST doesn't match", "TOK_ROLLBACK", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", "tok_rollback", ast.toStringTree()); ast = parse("ROLLBACK WORK"); - Assert.assertEquals("AST doesn't match", "TOK_ROLLBACK", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", "tok_rollback", ast.toStringTree()); } - + @Test public void testAutoCommit() throws ParseException { ASTNode ast = parse("SET AUTOCOMMIT TRUE"); - Assert.assertEquals("AST doesn't match", "(TOK_SET_AUTOCOMMIT TOK_TRUE)", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", "(tok_set_autocommit tok_true)", ast.toStringTree()); ast = parse("SET AUTOCOMMIT FALSE"); - Assert.assertEquals("AST doesn't match", "(TOK_SET_AUTOCOMMIT TOK_FALSE)", ast.toStringTree()); + Assert.assertEquals("AST doesn't match", "(tok_set_autocommit tok_false)", ast.toStringTree()); } } http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/queries/clientpositive/groupby_duplicate_key.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientpositive/groupby_duplicate_key.q b/ql/src/test/queries/clientpositive/groupby_duplicate_key.q index 7f38efe..1909873 100644 --- a/ql/src/test/queries/clientpositive/groupby_duplicate_key.q +++ b/ql/src/test/queries/clientpositive/groupby_duplicate_key.q @@ -11,3 +11,7 @@ create table dummy as select distinct key, "X" as dummy1, "X" as dummy2 from src tablesample (10 rows); select key,dummy1,dummy2 from dummy; + +explain +select max('pants'), max('pANTS') from src group by key limit 1; +select max('pants'), max('pANTS') from src group by key limit 1; http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/results/clientnegative/join_cond_unqual_ambiguous_vc.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientnegative/join_cond_unqual_ambiguous_vc.q.out b/ql/src/test/results/clientnegative/join_cond_unqual_ambiguous_vc.q.out index 06c1ab5..3d9735a 100644 --- a/ql/src/test/results/clientnegative/join_cond_unqual_ambiguous_vc.q.out +++ b/ql/src/test/results/clientnegative/join_cond_unqual_ambiguous_vc.q.out @@ -1 +1 @@ -FAILED: SemanticException Column input__file__name Found in more than One Tables/Subqueries +FAILED: SemanticException Column INPUT__FILE__NAME Found in more than One Tables/Subqueries http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/results/clientpositive/case_sensitivity.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/case_sensitivity.q.out b/ql/src/test/results/clientpositive/case_sensitivity.q.out index a5b14e8..b3969cc 100644 --- a/ql/src/test/results/clientpositive/case_sensitivity.q.out +++ b/ql/src/test/results/clientpositive/case_sensitivity.q.out @@ -35,7 +35,7 @@ STAGE PLANS: predicate: (lint[0] > 0) (type: boolean) Statistics: Num rows: 3 Data size: 837 Basic stats: COMPLETE Column stats: NONE Select Operator - expressions: lint[1] (type: int), lintstring[0].MYSTRING (type: string) + expressions: lint[1] (type: int), lintstring[0].mystring (type: string) outputColumnNames: _col0, _col1 Statistics: Num rows: 3 Data size: 837 Basic stats: COMPLETE Column stats: NONE File Output Operator http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/results/clientpositive/constant_prop.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/constant_prop.q.out b/ql/src/test/results/clientpositive/constant_prop.q.out index 1199709..001a3c8 100644 --- a/ql/src/test/results/clientpositive/constant_prop.q.out +++ b/ql/src/test/results/clientpositive/constant_prop.q.out @@ -33,7 +33,7 @@ STAGE PLANS: Row Limit Per Split: 1 Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: COMPLETE Select Operator - expressions: named_struct(if(array_contains(array(1,2), 3), 'F1', 'B1'),1,if(array_contains(map_keys(map('b':'x')), 'b'), 'F2', 'B2'),2) (type: struct), named_struct(if(array_contains(array(1,2), 3), 'F1', 'B1'),1,if(array_contains(map_keys(map('b':'x')), 'b'), 'F2', 'B2'),2).F2 (type: int) + expressions: named_struct(if(array_contains(array(1,2), 3), 'F1', 'B1'),1,if(array_contains(map_keys(map('b':'x')), 'b'), 'F2', 'B2'),2) (type: struct), named_struct(if(array_contains(array(1,2), 3), 'F1', 'B1'),1,if(array_contains(map_keys(map('b':'x')), 'b'), 'F2', 'B2'),2).f2 (type: int) outputColumnNames: _col0, _col1 Statistics: Num rows: 500 Data size: 30000 Basic stats: COMPLETE Column stats: COMPLETE ListSink http://git-wip-us.apache.org/repos/asf/hive/blob/54858565/ql/src/test/results/clientpositive/groupby_duplicate_key.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/groupby_duplicate_key.q.out b/ql/src/test/results/clientpositive/groupby_duplicate_key.q.out index fc95f41..8ca8866 100644 --- a/ql/src/test/results/clientpositive/groupby_duplicate_key.q.out +++ b/ql/src/test/results/clientpositive/groupby_duplicate_key.q.out @@ -175,3 +175,74 @@ POSTHOOK: Input: default@dummy 484 X X 86 X X 98 X X +PREHOOK: query: explain +select max('pants'), max('pANTS') from src group by key limit 1 +PREHOOK: type: QUERY +POSTHOOK: query: explain +select max('pants'), max('pANTS') from src group by key limit 1 +POSTHOOK: type: QUERY +STAGE DEPENDENCIES: + Stage-1 is a root stage + Stage-0 depends on stages: Stage-1 + +STAGE PLANS: + Stage: Stage-1 + Map Reduce + Map Operator Tree: + TableScan + alias: src + Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE + Select Operator + expressions: key (type: string) + outputColumnNames: key + Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE + Group By Operator + aggregations: max('pants'), max('pANTS') + keys: key (type: string) + mode: hash + outputColumnNames: _col0, _col1, _col2 + Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE + Reduce Output Operator + key expressions: _col0 (type: string) + sort order: + + Map-reduce partition columns: _col0 (type: string) + Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE + TopN Hash Memory Usage: 0.1 + value expressions: _col1 (type: string), _col2 (type: string) + Reduce Operator Tree: + Group By Operator + aggregations: max(VALUE._col0), max(VALUE._col1) + keys: KEY._col0 (type: string) + mode: mergepartial + outputColumnNames: _col0, _col1, _col2 + Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE Column stats: NONE + Select Operator + expressions: _col1 (type: string), _col2 (type: string) + outputColumnNames: _col0, _col1 + Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE Column stats: NONE + Limit + Number of rows: 1 + Statistics: Num rows: 1 Data size: 10 Basic stats: COMPLETE Column stats: NONE + File Output Operator + compressed: false + Statistics: Num rows: 1 Data size: 10 Basic stats: COMPLETE Column stats: NONE + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat + serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe + + Stage: Stage-0 + Fetch Operator + limit: 1 + Processor Tree: + ListSink + +PREHOOK: query: select max('pants'), max('pANTS') from src group by key limit 1 +PREHOOK: type: QUERY +PREHOOK: Input: default@src +#### A masked pattern was here #### +POSTHOOK: query: select max('pants'), max('pANTS') from src group by key limit 1 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src +#### A masked pattern was here #### +pants pANTS