diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/index/RewriteParseContextGenerator.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/index/RewriteParseContextGenerator.java index 0c111bc..f54e525 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/index/RewriteParseContextGenerator.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/index/RewriteParseContextGenerator.java @@ -113,7 +113,7 @@ sem.getMetaData(qb); LOG.info("Completed getting MetaData in Sub-query Semantic Analysis"); - LOG.info("Sub-query Abstract syntax tree: " + ast.toStringTree()); + LOG.info("Sub-query Abstract syntax tree: " + ast.toStringTree(true)); Operator operator = sem.genPlan(qb); LOG.info("Sub-query Completed plan generation"); 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 c8dbe97..d661d7a 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 @@ -31,8 +31,11 @@ */ public class ASTNode extends CommonTree implements Node,Serializable { private static final long serialVersionUID = 1L; - + private transient StringBuffer astStr; private transient ASTNodeOrigin origin; + private transient int startIndx = -1; + private transient int endIndx = -1; + private transient ASTNode rootNode; public ASTNode() { } @@ -81,6 +84,7 @@ public Tree dupNode() { * * @see org.apache.hadoop.hive.ql.lib.Node#getName() */ + @Override public String getName() { return (Integer.valueOf(super.getToken().getType())).toString(); } @@ -126,4 +130,81 @@ private StringBuilder dump(StringBuilder sb, String ws) { } return sb; } + + private ASTNode getRootNode () { + if (rootNode != null && rootNode.parent == null) { + return rootNode; + } + ASTNode retNode = this; + while (retNode.parent != null) { + retNode = (ASTNode) retNode.parent; + } + return rootNode=retNode; + } + + boolean hasValidMemoizedString() { + return astStr != null; + } + + int getMemoizedStringLen() { + return astStr == null ? 0 : astStr.length(); + } + + String getMemoizedSubString(int start, int end) { + return (astStr == null || start < 0 || end > astStr.length() || start >= end) ? null : + astStr.subSequence(start, end).toString(); + } + + void addtoMemoizedString(String string) { + if (astStr == null) { + astStr = new StringBuffer(); + } + astStr.append(string); + } + + /** + * Converts tree to string with an option to memoize the stringtree. + * + * @param useMemoizedString + * If true, use memoized string if available, else compute the + * stringtree from scratch. + */ + public String toStringTree(boolean useMemoizedString) { + if (!useMemoizedString) { + return super.toStringTree(); + } + ASTNode rootNode = (ASTNode)this.getRootNode(); + if (rootNode.hasValidMemoizedString() && startIndx >= 0 && + endIndx <= rootNode.getMemoizedStringLen()) { + return rootNode.getMemoizedSubString(startIndx, endIndx); + } + return toStringTree(rootNode); + } + + private String toStringTree(ASTNode rootNode) { + startIndx = rootNode.getMemoizedStringLen(); + // Leaf node + if ( children==null || children.size()==0 ) { + rootNode.addtoMemoizedString(this.toString()); + endIndx = rootNode.getMemoizedStringLen(); + return this.toString(); + } + if ( !isNil() ) { + rootNode.addtoMemoizedString("("); + rootNode.addtoMemoizedString(this.toString()); + rootNode.addtoMemoizedString(" "); + } + for (int i = 0; children!=null && i < children.size(); i++) { + ASTNode t = (ASTNode)children.get(i); + if ( i>0 ) { + rootNode.addtoMemoizedString(" "); + } + t.toStringTree(rootNode); + } + if ( !isNil() ) { + rootNode.addtoMemoizedString(")"); + } + endIndx = rootNode.getMemoizedStringLen(); + return rootNode.getMemoizedSubString(startIndx, endIndx); + } } 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 8b46d6c..63cda65 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 @@ -2463,7 +2463,7 @@ private RelNode genSelectRelNode(List calciteColLst, RowResolver out_rw if (windowExpressions != null ) { windowToAlias = new HashMap(); for (WindowExpressionSpec wes : windowExpressions) { - windowToAlias.put(wes.getExpression().toStringTree().toLowerCase(), wes.getAlias()); + windowToAlias.put(wes.getExpression().toStringTree(true).toLowerCase(), wes.getAlias()); } } String[] qualifiedColNames; @@ -2643,7 +2643,7 @@ private RelNode genSelectLogicalPlan(QB qb, RelNode srcRel, RelNode starSrcRel) SemanticAnalyzer.unescapeIdentifier(expr.getChild(0).getChild(0).getText() .toLowerCase()), expr, col_list, excludedColumns, inputRR, starRR, pos, out_rwsch, tabAliasesForAllProjs, true); - } else if (expr.toStringTree().contains("TOK_FUNCTIONDI") + } else if (expr.toStringTree(true).contains("TOK_FUNCTIONDI") && !(srcRel instanceof HiveAggregate)) { // Likely a malformed query eg, select hash(distinct c1) from t1; throw new CalciteSemanticException("Distinct without an aggreggation.", @@ -2898,7 +2898,7 @@ private void validateNoHavingReferenceToAlias(QB qb, ASTNode havingExpr) for (Map.Entry selExpr : exprToAlias.entrySet()) { ASTNode selAST = selExpr.getKey(); - if (!aggExprs.contains(selAST.toStringTree().toLowerCase())) { + if (!aggExprs.contains(selAST.toStringTree(true).toLowerCase())) { continue; } final String aliasToCheck = selExpr.getValue(); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFInvocationSpec.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFInvocationSpec.java index 06d3f4b..e2dcb3e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFInvocationSpec.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFInvocationSpec.java @@ -340,7 +340,7 @@ public void setExpression(ASTNode expression) { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((expression == null) ? 0 : expression.toStringTree().hashCode()); + result = prime * result + ((expression == null) ? 0 : expression.toStringTree(true).hashCode()); return result; } @@ -360,7 +360,7 @@ public boolean equals(Object obj) { if (other.expression != null) { return false; } - } else if (!expression.toStringTree().equals(other.expression.toStringTree())) { + } else if (!expression.toStringTree(true).equals(other.expression.toStringTree(true))) { return false; } return true; @@ -369,7 +369,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return expression.toStringTree(); + return expression.toStringTree(true); } } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFTranslator.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFTranslator.java index 00b43c6..a0953bb 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFTranslator.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/PTFTranslator.java @@ -281,7 +281,7 @@ private PartitionedTableFunctionDef translate(PartitionedTableFunctionSpec spec, def.setName(spec.getName()); def.setResolverClassName(tFn.getClass().getName()); def.setAlias(spec.getAlias() == null ? "ptf_" + inpNum : spec.getAlias()); - def.setExpressionTreeString(spec.getAstNode().toStringTree()); + def.setExpressionTreeString(spec.getAstNode().toStringTree(true)); def.setTransformsRawInput(tFn.transformsRawInput()); /* * translate args @@ -357,7 +357,7 @@ private WindowFunctionDef translate(WindowTableFunctionDef wdwTFnDef, def.setName(spec.getName()); def.setAlias(spec.getAlias()); def.setDistinct(spec.isDistinct()); - def.setExpressionTreeString(spec.getExpression().toStringTree()); + def.setExpressionTreeString(spec.getExpression().toStringTree(true)); def.setStar(spec.isStar()); def.setPivotResult(wFnInfo.isPivotResult()); ShapeDetails inpShape = wdwTFnDef.getRawInputShape(); @@ -472,7 +472,7 @@ private PTFExpressionDef translate(ShapeDetails inpShape, } PTFTranslator.validateComparable(expDef.getOI(), String.format("Partition Expression %s is not a comparable expression", pExpr - .getExpression().toStringTree())); + .getExpression().toStringTree(true))); return expDef; } @@ -510,7 +510,7 @@ private OrderExpressionDef translate(ShapeDetails inpShape, } PTFTranslator.validateComparable(oexpDef.getOI(), String.format("Partition Expression %s is not a comparable expression", - oExpr.getExpression().toStringTree())); + oExpr.getExpression().toStringTree(true))); return oexpDef; } @@ -706,8 +706,8 @@ private ShapeDetails setupShapeForNoop(ShapeDetails inpShape, chkSize = chkSize > orderCols.size() ? orderCols.size() : chkSize; for (int i = 0; i < chkSize; i++) { - if (orderCols.get(i).getExpression().toStringTree() - .equals(partCols.get(i).getExpression().toStringTree())) { + if (orderCols.get(i).getExpression().toStringTree(true) + .equals(partCols.get(i).getExpression().toStringTree(true))) { numOfPartColumns++; } else { break; @@ -764,7 +764,7 @@ public PTFExpressionDef buildExpressionDef(ShapeDetails inpShape, ASTNode arg) ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(llInfo, exprNode); ObjectInspector oi = initExprNodeEvaluator(exprEval, exprNode, inpShape); - argDef.setExpressionTreeString(arg.toStringTree()); + argDef.setExpressionTreeString(arg.toStringTree(true)); argDef.setExprNode(exprNode); argDef.setExprEvaluator(exprEval); argDef.setOI(oi); @@ -1141,7 +1141,7 @@ public void visit(Object t, Object parent, int childIndex, Map labels) { void checkValid() throws SemanticException { if (throwError) { - throw new SemanticException(errMsg + errorNode.toStringTree()); + throw new SemanticException(errMsg + errorNode.toStringTree(true)); } } } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/QBParseInfo.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/QBParseInfo.java index 14a7e9c..fd3afdc 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/QBParseInfo.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/QBParseInfo.java @@ -199,7 +199,7 @@ public void addWindowingExprToClause(String clause, ASTNode windowingExprNode) { windowingExprs = new LinkedHashMap(); destToWindowingExprs.put(clause, windowingExprs); } - windowingExprs.put(windowingExprNode.toStringTree(), windowingExprNode); + windowingExprs.put(windowingExprNode.toStringTree(true), windowingExprNode); } public HashMap getWindowingExprsForClause(String clause) { 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 5190bda..620b910 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 @@ -73,7 +73,7 @@ public RowResolver() { * string rendering of the ASTNode as the column alias. */ public void putExpression(ASTNode node, ColumnInfo colInfo) { - String treeAsString = node.toStringTree(); + String treeAsString = node.toStringTree(true); expressionMap.put(treeAsString, node); put("", treeAsString, colInfo); } @@ -83,7 +83,7 @@ public void putExpression(ASTNode node, ColumnInfo colInfo) { * exactly matches the string rendering of the given ASTNode. */ public ColumnInfo getExpression(ASTNode node) throws SemanticException { - return get("", node.toStringTree()); + return get("", node.toStringTree(true)); } /** @@ -91,7 +91,7 @@ public ColumnInfo getExpression(ASTNode node) throws SemanticException { * string rendering exactly. */ public ASTNode getExpressionSource(ASTNode node) { - return expressionMap.get(node.toStringTree()); + return expressionMap.get(node.toStringTree(true)); } public void put(String tab_alias, String col_alias, ColumnInfo colInfo) { 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 a52f2f2..4603bde 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 @@ -479,7 +479,7 @@ public void doPhase1QBExpr(ASTNode ast, QBExpr qbexpr, String id, String alias) (ASTNode)wdwFn.getChild(wdwFn.getChildCount()-1)); // If this is a duplicate invocation of a function; don't add to WindowingSpec. if ( wExprsInDest != null && - wExprsInDest.containsKey(wFnSpec.getExpression().toStringTree())) { + wExprsInDest.containsKey(wFnSpec.getExpression().toStringTree(true))) { continue; } wFnSpec.setAlias(wFnSpec.getName() + "_window_" + wColIdx); @@ -534,7 +534,7 @@ private void doPhase1GetAllAggregations(ASTNode expressionTree, if(containsLeadLagUDF(expressionTree)) { throw new SemanticException(ErrorMsg.MISSING_OVER_CLAUSE.getMsg(functionName)); } - aggregations.put(expressionTree.toStringTree().toLowerCase(), expressionTree); + aggregations.put(expressionTree.toStringTree(true).toLowerCase(), expressionTree); FunctionInfo fi = FunctionRegistry.getFunctionInfo(functionName); if (!fi.isNative()) { unparseTranslator.addIdentifierTranslation((ASTNode) expressionTree @@ -2206,7 +2206,7 @@ void parseJoinCondPopulateAlias(QBJoinTree joinTree, ASTNode condn, leftAliases, rightAliases, fields1, aliasToOpInfo); } } else { - throw new SemanticException(condn.toStringTree() + " encountered with " + throw new SemanticException(condn.toStringTree(true) + " encountered with " + condn.getChildCount() + " children"); } break; @@ -3433,7 +3433,7 @@ private Operator genScriptPlan(ASTNode trfm, QB qb, Operator input) Map exprPos = new HashMap(); for (int i = 0; i < groupByExpr.size(); ++i) { ASTNode node = groupByExpr.get(i); - exprPos.put(node.toStringTree(), i); + exprPos.put(node.toStringTree(true), i); } ASTNode root = parseInfo.getGroupByForClause(dest); @@ -3446,7 +3446,7 @@ private Operator genScriptPlan(ASTNode trfm, QB qb, Operator input) } int bitmap = 0; for (int j = 0; j < child.getChildCount(); ++j) { - String treeAsString = child.getChild(j).toStringTree(); + String treeAsString = ((ASTNode)(child.getChild(j))).toStringTree(true); Integer pos = exprPos.get(treeAsString); if (pos == null) { throw new SemanticException( @@ -3499,7 +3499,7 @@ public static int setBit(int bitmap, int bitIdx) { /* * If this is handled by Windowing then ignore it. */ - if (windowingExprs != null && windowingExprs.containsKey(grpbyExpr.toStringTree())) { + if (windowingExprs != null && windowingExprs.containsKey(grpbyExpr.toStringTree(true))) { continue; } result.add(grpbyExpr); @@ -3567,7 +3567,7 @@ public static int setBit(int bitmap, int bitIdx) { // if specified generate alias using func name if (includeFuncName && (root.getType() == HiveParser.TOK_FUNCTION)) { - String expr_flattened = root.toStringTree(); + String expr_flattened = root.toStringTree(true); // remove all TOK tokens String expr_no_tok = expr_flattened.replaceAll("TOK_\\S+", ""); @@ -3630,7 +3630,7 @@ static boolean isRegex(String pattern, HiveConf conf) { Operator inputForSelectStar, boolean outerLV) throws SemanticException { if (LOG.isDebugEnabled()) { - LOG.debug("tree: " + selExprList.toStringTree()); + LOG.debug("tree: " + selExprList.toStringTree(true)); } ArrayList col_list = new ArrayList(); @@ -8474,10 +8474,10 @@ private void mergeJoins(QB qb, QBJoinTree node, QBJoinTree target, int pos, int[ boolean[] nodeFiltersMapped = new boolean[nodeCondn.size()]; int i, j; for(i=0; i (. (TOK_TABLE_OR_COL s1) key) '9') (> (. (TOK_TABLE_OR_COL s1) value) '9'))))) (. (TOK_TABLE_OR_COL src) key))" ); } @@ -88,8 +88,8 @@ public void testExtractConjuncts() throws Exception { 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(conjuncts.get(0).toStringTree(true), "(> (. (TOK_TABLE_OR_COL s1) key) '9')"); + Assert.assertEquals(conjuncts.get(1).toStringTree(true), "(> (. (TOK_TABLE_OR_COL s1) value) '9')"); } @Test @@ -100,7 +100,7 @@ public void testRewriteOuterQueryWhere() throws Exception { ASTNode sq = sqs.get(0); ASTNode newWhere = SubQueryUtils.rewriteParentQueryWhere((ASTNode) where.getChild(0), sq); - Assert.assertEquals(newWhere.toStringTree(), "(= 1 1)"); + Assert.assertEquals(newWhere.toStringTree(true), "(= 1 1)"); } @Test @@ -111,7 +111,7 @@ public void testRewriteOuterQueryWhere2() throws Exception { 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(newWhere.toStringTree(true), "(> (TOK_TABLE_OR_COL value) '9')"); } @Test 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 4c84e91..ede5e20 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 @@ -66,7 +66,7 @@ public void testSQL11ReservedKeyWords_ALL() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME ALL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -76,7 +76,7 @@ public void testSQL11ReservedKeyWords_ALTER() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME ALTER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -86,7 +86,7 @@ public void testSQL11ReservedKeyWords_ARRAY() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME ARRAY) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -96,7 +96,7 @@ public void testSQL11ReservedKeyWords_AS() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME AS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -106,7 +106,7 @@ public void testSQL11ReservedKeyWords_AUTHORIZATION() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME AUTHORIZATION) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -116,7 +116,7 @@ public void testSQL11ReservedKeyWords_BETWEEN() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME BETWEEN) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -126,7 +126,7 @@ public void testSQL11ReservedKeyWords_BIGINT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME BIGINT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -136,7 +136,7 @@ public void testSQL11ReservedKeyWords_BINARY() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME BINARY) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -146,7 +146,7 @@ public void testSQL11ReservedKeyWords_BOOLEAN() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME BOOLEAN) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -156,7 +156,7 @@ public void testSQL11ReservedKeyWords_BOTH() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME BOTH) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -166,7 +166,7 @@ public void testSQL11ReservedKeyWords_BY() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME BY) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -176,7 +176,7 @@ public void testSQL11ReservedKeyWords_CREATE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME CREATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -186,7 +186,7 @@ public void testSQL11ReservedKeyWords_CUBE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME CUBE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -196,7 +196,7 @@ public void testSQL11ReservedKeyWords_CURRENT_DATE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME CURRENT_DATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -206,7 +206,7 @@ public void testSQL11ReservedKeyWords_CURRENT_TIMESTAMP() throws ParseException .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME CURRENT_TIMESTAMP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -216,7 +216,7 @@ public void testSQL11ReservedKeyWords_CURSOR() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME CURSOR) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -226,7 +226,7 @@ public void testSQL11ReservedKeyWords_DATE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME DATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -236,7 +236,7 @@ public void testSQL11ReservedKeyWords_DECIMAL() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME DECIMAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -246,7 +246,7 @@ public void testSQL11ReservedKeyWords_DELETE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME DELETE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -256,7 +256,7 @@ public void testSQL11ReservedKeyWords_DESCRIBE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME DESCRIBE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -266,7 +266,7 @@ public void testSQL11ReservedKeyWords_DOUBLE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME DOUBLE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -276,7 +276,7 @@ public void testSQL11ReservedKeyWords_DROP() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME DROP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -286,7 +286,7 @@ public void testSQL11ReservedKeyWords_EXISTS() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME EXISTS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -296,7 +296,7 @@ public void testSQL11ReservedKeyWords_EXTERNAL() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME EXTERNAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -306,7 +306,7 @@ public void testSQL11ReservedKeyWords_FALSE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME FALSE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -316,7 +316,7 @@ public void testSQL11ReservedKeyWords_FETCH() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME FETCH) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -326,7 +326,7 @@ public void testSQL11ReservedKeyWords_FLOAT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME FLOAT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -336,7 +336,7 @@ public void testSQL11ReservedKeyWords_FOR() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME FOR) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -346,7 +346,7 @@ public void testSQL11ReservedKeyWords_FULL() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME FULL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -356,7 +356,7 @@ public void testSQL11ReservedKeyWords_GRANT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME GRANT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -366,7 +366,7 @@ public void testSQL11ReservedKeyWords_GROUP() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME GROUP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -376,7 +376,7 @@ public void testSQL11ReservedKeyWords_GROUPING() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME GROUPING) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -386,7 +386,7 @@ public void testSQL11ReservedKeyWords_IMPORT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME IMPORT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -396,7 +396,7 @@ public void testSQL11ReservedKeyWords_IN() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME IN) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -406,7 +406,7 @@ public void testSQL11ReservedKeyWords_INNER() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME INNER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -416,7 +416,7 @@ public void testSQL11ReservedKeyWords_INSERT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME INSERT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -426,7 +426,7 @@ public void testSQL11ReservedKeyWords_INT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME INT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -436,7 +436,7 @@ public void testSQL11ReservedKeyWords_INTERSECT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME INTERSECT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -446,7 +446,7 @@ public void testSQL11ReservedKeyWords_INTO() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME INTO) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -456,7 +456,7 @@ public void testSQL11ReservedKeyWords_IS() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME IS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -466,7 +466,7 @@ public void testSQL11ReservedKeyWords_LATERAL() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME LATERAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -476,7 +476,7 @@ public void testSQL11ReservedKeyWords_LEFT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME LEFT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -486,7 +486,7 @@ public void testSQL11ReservedKeyWords_LIKE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME LIKE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -496,7 +496,7 @@ public void testSQL11ReservedKeyWords_LOCAL() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME LOCAL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -506,7 +506,7 @@ public void testSQL11ReservedKeyWords_NONE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME NONE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -516,7 +516,7 @@ public void testSQL11ReservedKeyWords_NULL() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME NULL) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -526,7 +526,7 @@ public void testSQL11ReservedKeyWords_OF() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME OF) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -536,7 +536,7 @@ public void testSQL11ReservedKeyWords_ORDER() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME ORDER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -546,7 +546,7 @@ public void testSQL11ReservedKeyWords_OUT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME OUT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -556,7 +556,7 @@ public void testSQL11ReservedKeyWords_OUTER() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME OUTER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -566,7 +566,7 @@ public void testSQL11ReservedKeyWords_PARTITION() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME PARTITION) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -576,7 +576,7 @@ public void testSQL11ReservedKeyWords_PERCENT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME PERCENT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -586,7 +586,7 @@ public void testSQL11ReservedKeyWords_PROCEDURE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME PROCEDURE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -596,7 +596,7 @@ public void testSQL11ReservedKeyWords_RANGE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME RANGE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -606,7 +606,7 @@ public void testSQL11ReservedKeyWords_READS() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME READS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -616,7 +616,7 @@ public void testSQL11ReservedKeyWords_REVOKE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME REVOKE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -626,7 +626,7 @@ public void testSQL11ReservedKeyWords_RIGHT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME RIGHT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -636,7 +636,7 @@ public void testSQL11ReservedKeyWords_ROLLUP() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME ROLLUP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -646,7 +646,7 @@ public void testSQL11ReservedKeyWords_ROW() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME ROW) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -656,7 +656,7 @@ public void testSQL11ReservedKeyWords_ROWS() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME ROWS) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -666,7 +666,7 @@ public void testSQL11ReservedKeyWords_SET() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME SET) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -676,7 +676,7 @@ public void testSQL11ReservedKeyWords_SMALLINT() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME SMALLINT) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -686,7 +686,7 @@ public void testSQL11ReservedKeyWords_TABLE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME TABLE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -696,7 +696,7 @@ public void testSQL11ReservedKeyWords_TIMESTAMP() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME TIMESTAMP) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -706,7 +706,7 @@ public void testSQL11ReservedKeyWords_TO() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME TO) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -716,7 +716,7 @@ public void testSQL11ReservedKeyWords_TRIGGER() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME TRIGGER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -726,7 +726,7 @@ public void testSQL11ReservedKeyWords_TRUE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME TRUE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -736,7 +736,7 @@ public void testSQL11ReservedKeyWords_TRUNCATE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME TRUNCATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -746,7 +746,7 @@ public void testSQL11ReservedKeyWords_UNION() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME UNION) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -756,7 +756,7 @@ public void testSQL11ReservedKeyWords_UPDATE() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME UPDATE) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -766,7 +766,7 @@ public void testSQL11ReservedKeyWords_USER() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME USER) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -776,7 +776,7 @@ public void testSQL11ReservedKeyWords_USING() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME USING) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -786,7 +786,7 @@ public void testSQL11ReservedKeyWords_VALUES() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME VALUES) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } @Test @@ -796,6 +796,6 @@ public void testSQL11ReservedKeyWords_WITH() throws ParseException { .assertEquals( "AST doesn't match", "(TOK_CREATETABLE (TOK_TABNAME WITH) TOK_LIKETABLE (TOK_TABCOLLIST (TOK_TABCOL col TOK_STRING)))", - ast.toStringTree()); + ast.toStringTree(true)); } }