avoid a few exceptions
Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/bd1160a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/bd1160a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/bd1160a4 Branch: refs/heads/vxquery_0_3_staging Commit: bd1160a4493a9a340d1dd880d9b0587b6a0fe726 Parents: c13ad12 Author: Till Westmann <[email protected]> Authored: Thu Apr 3 22:05:49 2014 -0700 Committer: Preston Carman <[email protected]> Committed: Sun Apr 6 09:50:42 2014 -0700 ---------------------------------------------------------------------- ...ueryLogicalExpressionPrettyPrintVisitor.java | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/bd1160a4/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java index c630837..e6d8dd1 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/algebricks/prettyprint/VXQueryLogicalExpressionPrettyPrintVisitor.java @@ -40,6 +40,7 @@ import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.StatefulFunctionC import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression; import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression; import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; +import edu.uci.ics.hyracks.algebricks.core.algebra.functions.IFunctionInfo; import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionVisitor; import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable; @@ -90,7 +91,23 @@ public class VXQueryLogicalExpressionPrettyPrintVisitor implements ILogicalExpre @Override public String visitAggregateFunctionCallExpression(AggregateFunctionCallExpression expr, Integer indent) throws AlgebricksException { - return appendFunction(new StringBuilder(), expr, indent).toString(); + if (expr.isTwoStep()) { + IFunctionInfo step1Agg = expr.getStepOneAggregate(); + String step1 = (step1Agg != null ? step1Agg.getFunctionIdentifier().toString() : "null"); + IFunctionInfo step2Agg = expr.getStepTwoAggregate(); + String step2 = (step2Agg != null ? step2Agg.getFunctionIdentifier().toString() : "null"); + StringBuilder sb = new StringBuilder(); + sb.append("function-call: [" + step1 + "|" + step2 + "], Args:"); + appendArguments(sb, expr.getArguments(), indent + 2); + return sb.toString(); + } else if (expr.getFunctionInfo() == null) { + StringBuilder sb = new StringBuilder(); + sb.append("function-call: [null], Args:"); + appendArguments(sb, expr.getArguments(), indent + 2); + return sb.toString(); + } else { + return appendFunction(new StringBuilder(), expr, indent).toString(); + } } @Override @@ -138,15 +155,16 @@ public class VXQueryLogicalExpressionPrettyPrintVisitor implements ILogicalExpre throws AlgebricksException { assert expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL; FunctionIdentifier fi = expr.getFunctionIdentifier(); - if (identifiesTypeOperator(fi) || identifiesPathStep(fi)) { - final ILogicalExpression typeEx = expr.getArguments().get(1).getValue(); + List<Mutable<ILogicalExpression>> args = expr.getArguments(); + if ((identifiesTypeOperator(fi) || identifiesPathStep(fi)) && args.size() > 1) { + final ILogicalExpression typeEx = args.get(1).getValue(); assert typeEx.getExpressionTag() == LogicalExpressionTag.CONSTANT; SequenceType type = getSequenceType((ConstantExpression) typeEx); sb.append(fi + " <" + type + ">, Args:"); - appendArgument(sb, expr.getArguments().get(0), indent + 2); + appendArgument(sb, args.get(0), indent + 2); } else { sb.append("function-call: " + fi + ", Args:"); - appendArguments(sb, expr.getArguments(), indent + 2); + appendArguments(sb, args, indent + 2); } return sb; }
