vxquery-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From christ...@apache.org
Subject [1/3] vxquery git commit: VXQUERY-105: Add group-by functionality, Add scalability to JSON parser
Date Mon, 22 May 2017 18:11:55 GMT
Repository: vxquery
Updated Branches:
  refs/heads/master 2c881020c -> 53b86c24a


http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersUnnestingEvaluatorFactory.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersUnnestingEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersUnnestingEvaluatorFactory.java
new file mode 100644
index 0000000..3f94f7e
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/KeysOrMembersUnnestingEvaluatorFactory.java
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.vxquery.runtime.functions.json;
+
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IUnnestingEvaluator;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentUnnestingEvaluatorFactory;
+
+public class KeysOrMembersUnnestingEvaluatorFactory extends AbstractTaggedValueArgumentUnnestingEvaluatorFactory {
+    private static final long serialVersionUID = 1L;
+
+    public KeysOrMembersUnnestingEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IUnnestingEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+            throws HyracksDataException {
+        return new KeysOrMembersUnnestingEvaluator(ctx, args);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java
index eb71923..8627658 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/ASTTag.java
@@ -111,5 +111,7 @@ public enum ASTTag {
     ARRAY_CONSTRUCTOR,
     OBJECT_CONSTRUCTOR,
     SIMPLE_OBJECT_UNION_CONSTRUCTOR,
-    PAIR_CONSTRUCTOR
+    PAIR_CONSTRUCTOR,
+    GROUPBY_CLAUSE,
+    GROUP_SPECIFICATION
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupSpecNode.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupSpecNode.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupSpecNode.java
new file mode 100644
index 0000000..634bf66
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupSpecNode.java
@@ -0,0 +1,67 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.vxquery.xmlquery.ast;
+
+import org.apache.vxquery.util.SourceLocation;
+
+public class GroupSpecNode extends ASTNode {
+    private QNameNode varName;
+    private TypeDeclNode type;
+    private ASTNode expr;
+    private String collation;
+
+    public GroupSpecNode(SourceLocation loc) {
+        super(loc);
+    }
+
+    @Override
+    public ASTTag getTag() {
+        return ASTTag.GROUP_SPECIFICATION;
+    }
+
+    public QNameNode getVar() {
+        return varName;
+    }
+
+    public void setDefaultVar(QNameNode varName) {
+        this.varName = varName;
+    }
+
+    public TypeDeclNode getType() {
+        return type;
+    }
+
+    public void setType(TypeDeclNode type) {
+        this.type = type;
+    }
+
+    public ASTNode getExpr() {
+        return expr;
+    }
+
+    public void setExpression(ASTNode expr) {
+        this.expr = expr;
+    }
+
+    public String getCollation() {
+        return collation;
+    }
+
+    public void setCollation(String collation) {
+        this.collation = collation;
+    }
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupbyClauseNode.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupbyClauseNode.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupbyClauseNode.java
new file mode 100644
index 0000000..ee58b7a
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/ast/GroupbyClauseNode.java
@@ -0,0 +1,42 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.vxquery.xmlquery.ast;
+
+import java.util.List;
+
+import org.apache.vxquery.util.SourceLocation;
+
+public class GroupbyClauseNode extends FLWORClauseNode {
+    private List<GroupSpecNode> groupSpec;
+
+    public GroupbyClauseNode(SourceLocation loc) {
+        super(loc);
+    }
+
+    @Override
+    public ASTTag getTag() {
+        return ASTTag.GROUPBY_CLAUSE;
+    }
+
+    public List<GroupSpecNode> getGroupSpec() {
+        return groupSpec;
+    }
+
+    public void setGroupSpec(List<GroupSpecNode> groupSpec) {
+        this.groupSpec = groupSpec;
+    }
+}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
index b7839d0..0c252b4 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
@@ -84,6 +84,8 @@ public class XMLQueryCompiler {
 
     private LogicalOperatorPrettyPrintVisitor pprinter;
 
+    private VXQueryLogicalExpressionPrettyPrintVisitor epprinter;
+
     private ModuleNode moduleNode;
 
     private Module module;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryParser.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryParser.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryParser.java
index 04690f5..9aa7d9a 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryParser.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryParser.java
@@ -37,8 +37,8 @@ public class XMLQueryParser {
             if (!exceptions.isEmpty()) {
                 throw exceptions.get(0);
             }
-            throw new SystemException(ErrorCode.XPST0003, new SourceLocation(sourceName, pe.currentToken.beginLine,
-                    pe.currentToken.beginColumn));
+            SourceLocation loc = new SourceLocation(sourceName, pe.currentToken.beginLine, pe.currentToken.beginColumn);
+            throw new SystemException(ErrorCode.XPST0003, loc, pe);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
index 3d95cb1..6d0b35a 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/translator/XMLQueryTranslator.java
@@ -21,10 +21,14 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.ListIterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -33,12 +37,14 @@ import javax.xml.namespace.QName;
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.commons.lang3.mutable.MutableObject;
 import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan;
 import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
 import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
 import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
+import org.apache.hyracks.algebricks.core.algebra.base.OperatorAnnotations;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
@@ -49,12 +55,14 @@ import org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOpe
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.DistributeResultOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.NestedTupleSourceOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.SelectOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator;
 import org.apache.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl;
+import org.apache.hyracks.algebricks.core.algebra.typing.ITypingContext;
 import org.apache.hyracks.data.std.primitive.DoublePointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
@@ -134,6 +142,8 @@ import org.apache.vxquery.xmlquery.ast.ForClauseNode;
 import org.apache.vxquery.xmlquery.ast.ForVarDeclNode;
 import org.apache.vxquery.xmlquery.ast.FunctionDeclNode;
 import org.apache.vxquery.xmlquery.ast.FunctionExprNode;
+import org.apache.vxquery.xmlquery.ast.GroupSpecNode;
+import org.apache.vxquery.xmlquery.ast.GroupbyClauseNode;
 import org.apache.vxquery.xmlquery.ast.IfExprNode;
 import org.apache.vxquery.xmlquery.ast.InfixExprNode;
 import org.apache.vxquery.xmlquery.ast.InfixExprNode.InfixOperator;
@@ -768,7 +778,7 @@ public class XMLQueryTranslator {
                 return translateQuantifiedExprNode(tCtx, qeNode);
             }
 
-            /*
+                /*
                     case TYPESWITCH_EXPRESSION: {
                         TypeswitchExprNode teNode = (TypeswitchExprNode) value;
                         Expression sExpr = translateExpression(teNode.getSwitchExpr());
@@ -1143,6 +1153,69 @@ public class XMLQueryTranslator {
                     order.getInputs().add(mutable(tCtx.op));
                     tCtx.op = order;
                     break;
+
+                }
+                case GROUPBY_CLAUSE: {
+                    GroupbyClauseNode gcNode = (GroupbyClauseNode) cNode;
+                    GroupByOperator group = new GroupByOperator();
+                    ArrayList<XQueryVariable> al = new ArrayList<XQueryVariable>();
+                    ArrayList<ILogicalExpression> expr = new ArrayList<ILogicalExpression>();
+                    ArrayList<QName> qvar = new ArrayList<QName>();
+                    ArrayList<TypeDeclNode> stype = new ArrayList<TypeDeclNode>();
+                    //set the groupbyexpression list of the group by operator
+                    for (GroupSpecNode gsNode : gcNode.getGroupSpec()) {//data and createAssignment
+                        if (gsNode.getExpr() != null) {
+                            expr.add(vre(createAssignment(
+                                    zeroOrOne(data(vre(translateExpression(gsNode.getExpr(), tCtx)))), tCtx)));
+                        } else {
+                            XQueryVariable x = tCtx.varScope.lookupVariable(createQName(gsNode.getVar()));
+                            expr.add(vre(createAssignment(data(vre(x.getLogicalVariable())), tCtx)));
+                        }
+                        qvar.add(createQName(gsNode.getVar()));
+                        stype.add(gsNode.getType());
+                    }
+                    while (pushCount > 0) {
+                        al.add(tCtx.varScope.listVariables().next());
+                        tCtx.popVariableScope();
+                        --pushCount;
+                    }
+                    group.getInputs().add(mutable(tCtx.op));
+                    for (int i = 0; i < qvar.size(); i++) {
+                        LogicalVariable groupVar = newLogicalVariable();
+                        tCtx.pushVariableScope();
+                        SequenceType groupVarType = SequenceType.create(BuiltinTypeRegistry.XS_ANY_ATOMIC,
+                                Quantifier.QUANT_QUESTION);
+                        if (stype.get(i) != null) {
+                            groupVarType = createSequenceType(stype.get(i));
+                        }
+                        XQueryVariable z = new XQueryVariable(qvar.get(i), groupVarType, groupVar);
+                        tCtx.varScope.registerVariable(z);
+                        group.addGbyExpression(groupVar, expr.get(i));
+                        ++pushCount;
+                    }
+
+                    //set the nested plans of the group by operator
+                    for (int j = 0; j < al.size(); j++) {
+                        XQueryVariable xqv = al.get(j);
+                        ILogicalExpression sequenceInput = vre(xqv.getLogicalVariable());
+                        tCtx.pushVariableScope();
+                        AggregateFunctionCallExpression fsequence = (AggregateFunctionCallExpression) afce(
+                                BuiltinOperators.SEQUENCE, false, sequenceInput);
+                        LogicalVariable aggVar = newLogicalVariable();
+                        AggregateOperator agg = new AggregateOperator(mkSingletonArrayList(aggVar),
+                                mkSingletonArrayList(new MutableObject<>(fsequence)));
+                        agg.getInputs()
+                                .add(new MutableObject<>(new NestedTupleSourceOperator(new MutableObject<>(group))));
+                        ILogicalPlan plan = new ALogicalPlanImpl(new MutableObject<>(agg));
+                        group.getNestedPlans().add(plan);
+                        SequenceType aggVarType = SequenceType.create(xqv.getType().getItemType(),
+                                Quantifier.QUANT_STAR);
+                        XQueryVariable nagg = new XQueryVariable(xqv.getName(), aggVarType, aggVar);
+                        tCtx.varScope.registerVariable(nagg);
+                        pushCount++;
+                    }
+                    tCtx.op = group;
+                    break;
                 }
                 default:
                     throw new IllegalStateException("Unknown clause: " + cNode.getTag());
@@ -1164,6 +1237,12 @@ public class XMLQueryTranslator {
         return var;
     }
 
+    protected <T> List<T> mkSingletonArrayList(T item) {
+        ArrayList<T> array = new ArrayList<>(1);
+        array.add(item);
+        return array;
+    }
+
     private LogicalVariable translateVarRefNode(TranslationContext tCtx, VarRefNode vrNode) throws SystemException {
         QName vName = createQName(vrNode.getVariable());
         XQueryVariable var = tCtx.varScope.lookupVariable(vName);
@@ -1580,8 +1659,10 @@ public class XMLQueryTranslator {
                                 }
                                 if (arguments.size() == 0) {
                                     if (ctxExpr == null) {
+                                        ctxExpr = vre(createAssignment(expr, tCtx));
                                         ctxExpr = sfce(BuiltinOperators.KEYS_OR_MEMBERS, expr);
                                     } else {
+                                        ctxExpr = vre(createAssignment(ctxExpr, tCtx));
                                         ctxExpr = sfce(BuiltinOperators.KEYS_OR_MEMBERS, ctxExpr);
                                     }
                                 }
@@ -2107,6 +2188,11 @@ public class XMLQueryTranslator {
         return new ScalarFunctionCallExpression(BuiltinFunctions.FN_DATA_1, Collections.singletonList(mutable(expr)));
     }
 
+    private ILogicalExpression zeroOrOne(ILogicalExpression expr) throws SystemException {
+        return new ScalarFunctionCallExpression(BuiltinFunctions.FN_ZERO_OR_ONE_1,
+                Collections.singletonList(mutable(expr)));
+    }
+
     private ILogicalExpression string(ILogicalExpression expr) throws SystemException {
         return new ScalarFunctionCallExpression(BuiltinFunctions.FN_STRING_1, Collections.singletonList(mutable(expr)));
     }
@@ -2177,6 +2263,11 @@ public class XMLQueryTranslator {
         public void registerVariable(XQueryVariable var) {
             moduleCtx.registerVariable(var);
         }
+
+        @Override
+        public Iterator<XQueryVariable> listVariables() {
+            return moduleCtx.listVariables();
+        }
     }
 
     private class TranslationContext {
@@ -2222,6 +2313,8 @@ public class XMLQueryTranslator {
         public XQueryVariable lookupVariable(QName name);
 
         public void registerVariable(XQueryVariable var);
+
+        public Iterator<XQueryVariable> listVariables();
     }
 
     private static class ExpressionVariableScope implements IVariableScope {
@@ -2251,5 +2344,10 @@ public class XMLQueryTranslator {
         public void registerVariable(XQueryVariable var) {
             varMap.put(var.getName(), var);
         }
+
+        public Iterator<XQueryVariable> listVariables() {
+            return varMap.values().iterator();
+        }
+
     }
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/javacc/xquery-grammar.jj
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/javacc/xquery-grammar.jj b/vxquery-core/src/main/javacc/xquery-grammar.jj
index bfb5d26..38e96d8 100644
--- a/vxquery-core/src/main/javacc/xquery-grammar.jj
+++ b/vxquery-core/src/main/javacc/xquery-grammar.jj
@@ -716,7 +716,7 @@ ASTNode FLWORExpr()  :
     ASTNode rExpr;
 }
 {
-    ((ForClause(clauses) | LetClause(clauses)))+  [WhereClause(clauses)] [OrderByClause(clauses)] "return" rExpr = ExprSingle()
+    (ForClause(clauses) | LetClause(clauses)) (ForClause(clauses) | LetClause(clauses) | WhereClause(clauses) | GroupByClause(clauses) | OrderByClause(clauses))* "return" rExpr = ExprSingle()
     {
         FLWORExprNode flwor = new FLWORExprNode(clauses.get(0).getSourceLocation());
         flwor.setClauses(clauses);
@@ -912,6 +912,66 @@ void OrderModifier(OrderSpecNode os)  :
     }
 }
 
+void GroupByClause(List<FLWORClauseNode> clauses)  :
+{
+    List<GroupSpecNode> gsList;
+    Token start;
+}
+{
+    start = "group" "by" gsList = GroupSpecList() {
+        GroupbyClauseNode gc = new GroupbyClauseNode(createSourceLocation(start));
+        gc.setGroupSpec(gsList);
+        clauses.add(gc);
+    }
+}
+
+List<GroupSpecNode> GroupSpecList()  :
+{
+    List<GroupSpecNode> gsList = new ArrayList<GroupSpecNode>();
+    GroupSpecNode gs;
+}
+{
+    gs = GroupSpec() {
+        gsList.add(gs);
+    } (
+        "," gs = GroupSpec() {
+            gsList.add(gs);
+        }
+    )* {
+        return gsList;
+    }
+}
+
+GroupSpecNode GroupSpec()  :
+{
+   
+    QNameNode varName;
+    ASTNode expr = null;
+    TypeDeclNode type = null;
+    GroupSpecNode gs;
+    String collation = null;
+}
+{
+    varName = GroupingVariable() [[type=TypeDeclaration()] ":=" expr=ExprSingle()] ["collation" collation = URILiteral()]{
+        gs = new GroupSpecNode(varName.getSourceLocation());
+        gs.setDefaultVar(varName);
+        gs.setType(type);
+        gs.setExpression(expr);
+        gs.setCollation(collation);
+        return gs;
+    } 
+}
+
+QNameNode GroupingVariable()  :
+{
+    QNameNode qname;
+}
+{
+    "$" qname = VarName() {
+        return qname;
+    }
+}
+
 QuantifiedExprNode QuantifiedExpr() :
 {
     Token some = null;
@@ -3281,6 +3341,9 @@ QNameNode FunctionQName()  :
     | t = "order"  {
         return createQName(t);
     }
+    | t = "group"  {
+        return createQName(t);
+    }
     | t = "empty"  {
         return createQName(t);
     }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-core/src/main/xslt/generate-op-defns.xsl
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/xslt/generate-op-defns.xsl b/vxquery-core/src/main/xslt/generate-op-defns.xsl
index f706370..64f1218 100644
--- a/vxquery-core/src/main/xslt/generate-op-defns.xsl
+++ b/vxquery-core/src/main/xslt/generate-op-defns.xsl
@@ -57,31 +57,29 @@
                             );
                         </xsl:if>
                     </xsl:for-each>
-                    <xsl:for-each select="runtime">
-                        <xsl:if test="@type = 'scalar'">
-                        this.scalarEvaluatorFactory = true;
-                        </xsl:if>
-                        <xsl:if test="@type = 'aggregate'">
-                        this.aggregateEvaluatorFactory = true;
-                        </xsl:if>
-                        <xsl:if test="@type = 'unnesting'">
-                        this.unnestingEvaluatorFactory = true;
-                        </xsl:if>
-                    </xsl:for-each>
                     }
                 </xsl:if>
                 <xsl:for-each select="runtime">
                     <xsl:if test="@type = 'scalar'">
+                    {
+                         this.scalarEvaluatorFactory = true;
+                    }
                     public org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory createScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory[] args) {
                         return new <xsl:value-of select="@class"/>(args);
                     }
                     </xsl:if>
                     <xsl:if test="@type = 'aggregate'">
+                    {
+                        this.aggregateEvaluatorFactory = true;
+                    }
                     public org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory createAggregateEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory[] args) {
                         return new <xsl:value-of select="@class"/>(args);
                     }
                     </xsl:if>
                     <xsl:if test="@type = 'unnesting'">
+                    {
+                        this.unnestingEvaluatorFactory = true;
+                    }
                     public org.apache.hyracks.algebricks.runtime.base.IUnnestingEvaluatorFactory createUnnestingEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory[] args) {
                         return new <xsl:value-of select="@class"/>(args);
                     }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group.txt
new file mode 100644
index 0000000..2057a08
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group.txt
@@ -0,0 +1,4 @@
+{"date":"2001-01-01T00:00:00.000","value":[<value>11.25</value>,<value>31</value>,<value>1000</value>]}
+{"date":"2002-02-02T00:00:00.000","value":[<value>12.5</value>,<value>32</value>,<value>20</value>]}
+{"date":"2003-03-03T00:00:00.000","value":[<value>13.75</value>,<value>33</value>]}
+{"date":"2004-04-04T00:00:00.000","value":[<value>40</value>,<value>4</value>]}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json.txt
new file mode 100644
index 0000000..e27fe3d
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json.txt
@@ -0,0 +1,4 @@
+2001-01-01T00:00:00.000
+2002-02-02T00:00:00.000
+2003-03-03T00:00:00.000
+2004-04-04T00:00:00.000

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json_count.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json_count.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json_count.txt
new file mode 100644
index 0000000..601478f
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Groups/group_json_count.txt
@@ -0,0 +1,4 @@
+3
+3
+3
+1

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q15_parser.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q15_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q15_parser.txt
new file mode 100644
index 0000000..3ca741c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q15_parser.txt
@@ -0,0 +1,3 @@
+{"date":"2001-01-01T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000001","attributes":",,","value":11.25}
+{"date":"2002-02-02T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000002","attributes":",,","value":12.5}
+{"date":"2003-03-03T00:00:00.000","datatype":"TMIN","station":"GHCND:AS000000003","attributes":",,","value":13.75}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q16_parser.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q16_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q16_parser.txt
new file mode 100644
index 0000000..abbafea
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-1/q16_parser.txt
@@ -0,0 +1,3 @@
+{"date":"2001-01-01T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000001","attributes":",,","value":11.25}
+{"date":"2001-01-01T00:00:00.000","datatype":"TMAX","station":"GHCND:US000000001","attributes":",,","value":31}
+{"date":"2001-01-01T00:00:00.000","datatype":"AWND","station":"GHCND:US000000001","attributes":",,","value":1000}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q14_parser.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q14_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q14_parser.txt
new file mode 100644
index 0000000..abbafea
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q14_parser.txt
@@ -0,0 +1,3 @@
+{"date":"2001-01-01T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000001","attributes":",,","value":11.25}
+{"date":"2001-01-01T00:00:00.000","datatype":"TMAX","station":"GHCND:US000000001","attributes":",,","value":31}
+{"date":"2001-01-01T00:00:00.000","datatype":"AWND","station":"GHCND:US000000001","attributes":",,","value":1000}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q16_parser.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q16_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q16_parser.txt
new file mode 100644
index 0000000..abbafea
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-2/q16_parser.txt
@@ -0,0 +1,3 @@
+{"date":"2001-01-01T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000001","attributes":",,","value":11.25}
+{"date":"2001-01-01T00:00:00.000","datatype":"TMAX","station":"GHCND:US000000001","attributes":",,","value":31}
+{"date":"2001-01-01T00:00:00.000","datatype":"AWND","station":"GHCND:US000000001","attributes":",,","value":1000}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q14_parser.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q14_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q14_parser.txt
new file mode 100644
index 0000000..abbafea
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q14_parser.txt
@@ -0,0 +1,3 @@
+{"date":"2001-01-01T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000001","attributes":",,","value":11.25}
+{"date":"2001-01-01T00:00:00.000","datatype":"TMAX","station":"GHCND:US000000001","attributes":",,","value":31}
+{"date":"2001-01-01T00:00:00.000","datatype":"AWND","station":"GHCND:US000000001","attributes":",,","value":1000}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q15_parser.txt
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q15_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q15_parser.txt
new file mode 100644
index 0000000..3ca741c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/Partition-4/q15_parser.txt
@@ -0,0 +1,3 @@
+{"date":"2001-01-01T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000001","attributes":",,","value":11.25}
+{"date":"2002-02-02T00:00:00.000","datatype":"TMIN","station":"GHCND:US000000002","attributes":",,","value":12.5}
+{"date":"2003-03-03T00:00:00.000","datatype":"TMIN","station":"GHCND:AS000000003","attributes":",,","value":13.75}

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group.xq
new file mode 100644
index 0000000..e88c496
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group.xq
@@ -0,0 +1,24 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+   
+(: Return all the temperatures for each date :)
+let $sensor_collection := "ghcnd"
+for $i in collection($sensor_collection)/dataCollection/data
+group by $date := $i/date 
+order by data($date)
+return {"date":$date, "value":$i/value} 
+   
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json.xq
new file mode 100644
index 0000000..17be0f6
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json.xq
@@ -0,0 +1,25 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+   
+(: Return all the groups of dates :)  
+let $x:="jsonCollection"
+for $r in collection($x)
+let $z:=$r("results")()
+for $i in $z
+group by $date:=$i("date")
+order by $date
+return $date

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json_count.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json_count.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json_count.xq
new file mode 100644
index 0000000..9fea16c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Groups/group_json_count.xq
@@ -0,0 +1,27 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Return the number of records for each date :)  
+let $x:="jsonCollection"
+for $r in collection($x)
+let $z:=$r("results")()
+for $i in $z
+group by $date:= $i("date")
+order by $date
+let $count:=count($i)
+return $count
+

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Indexing/Partition-1/useIndex6.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Indexing/Partition-1/useIndex6.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Indexing/Partition-1/useIndex6.xq
index 537e4f1..c81f271 100644
--- a/vxquery-xtest/src/test/resources/Queries/XQuery/Indexing/Partition-1/useIndex6.xq
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Indexing/Partition-1/useIndex6.xq
@@ -20,4 +20,5 @@
 (: 2002-2-2.                                                                  :)
 for $s in collection-from-index("src/test/resources/TestSources/ghcnd", "/stationCollection/station")/station
 where (some $x in $s/locationLabels satisfies ($x/type eq "ST" and fn:upper-case(fn:data($x/displayName)) eq "STATE 1"))
+order by $s/id
 return $s

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q15_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q15_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q15_parser.xq
new file mode 100644
index 0000000..89555dc
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q15_parser.xq
@@ -0,0 +1,26 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Json Parser Query :)
+(: parse a string with arrays :)
+let $x:="jsonCollection"
+for $r in collection($x)
+    let $z:=$r("results")()
+    for $i in $z
+where $i("datatype")="TMIN"
+order by $i("date")
+return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q16_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q16_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q16_parser.xq
new file mode 100644
index 0000000..db4eaf8
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-1/q16_parser.xq
@@ -0,0 +1,25 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Json Parser Query :)
+(: parse a string with arrays :)
+let $x:="jsonCollection"
+for $r in collection($x)
+    let $z:=$r("results")()
+    for $i in $z
+where $i("station")="GHCND:US000000001"
+return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q14_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q14_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q14_parser.xq
new file mode 100644
index 0000000..f8b9fde
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q14_parser.xq
@@ -0,0 +1,25 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Json Parser Query :)
+(: parse a string with arrays :)
+let $x:="json_half_1|json_half_2"
+for $r in collection($x)
+    let $z:=$r("results")()
+    for $i in $z
+where $i("date")="2001-01-01T00:00:00.000"
+return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q16_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q16_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q16_parser.xq
new file mode 100644
index 0000000..58ef8fe
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-2/q16_parser.xq
@@ -0,0 +1,25 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Json Parser Query :)
+(: parse a string with arrays :)
+let $x:="json_half_1|json_half_2"
+for $r in collection($x)
+    let $z:=$r("results")()
+    for $i in $z
+where $i("station")="GHCND:US000000001"
+return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q14_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q14_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q14_parser.xq
new file mode 100644
index 0000000..12d028d
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q14_parser.xq
@@ -0,0 +1,25 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Json Parser Query :)
+(: parse a string with arrays :)
+let $x:="json_quarter_1|json_quarter_2|json_quarter_3|json_quarter_4"
+for $r in collection($x)
+    let $z:=$r("results")()
+    for $i in $z
+where $i("date")="2001-01-01T00:00:00.000"
+return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q15_parser.xq
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q15_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q15_parser.xq
new file mode 100644
index 0000000..6046303
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/Partition-4/q15_parser.xq
@@ -0,0 +1,25 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+     http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License. :)
+
+(: Json Parser Query :)
+(: parse a string with arrays :)
+let $x:="json_quarter_1|json_quarter_2|json_quarter_3|json_quarter_4"
+for $r in collection($x)
+    let $z:=$r("results")()
+    for $i in $z
+where $i("datatype")="TMIN"
+return $i

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
index 3fc9a72..5ecdb94 100644
--- a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
+++ b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
@@ -52,6 +52,7 @@
 <!ENTITY JsonParserQueries SYSTEM "cat/JsonParserQueries.xml">
 <!ENTITY LibrariesInJSONiq SYSTEM "cat/LibrariesInJSONiq.xml">
 <!ENTITY XMLInJSONQueries SYSTEM "cat/XMLInJSONQueries.xml">
+<!ENTITY GroupQueries SYSTEM "cat/GroupQueries.xml">
 
 <!ENTITY TraceQuery SYSTEM "cat/TraceQuery.xml">
 
@@ -274,6 +275,19 @@
          &IndexingQueries;
         </test-group>
     </test-group>
+    <test-group name="GroupQueries" featureOwner="Christina Pavlopoulou">
+        <GroupInfo>
+            <title>Group Queries</title>
+            <description/>
+        </GroupInfo>
+        <test-group name="GroupTests" featureOwner="Christina Pavlopoulou">
+            <GroupInfo>
+                <title>Group-by Tests</title>
+                <description/>
+            </GroupInfo>
+         &GroupQueries;
+        </test-group>
+    </test-group>
     <test-group name="JsoniqQueries" featureOwner="Christina Pavlopoulou">
         <GroupInfo>
             <title>Jsoniq Queries</title>

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/cat/GroupQueries.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/GroupQueries.xml b/vxquery-xtest/src/test/resources/cat/GroupQueries.xml
new file mode 100644
index 0000000..71cace0
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/cat/GroupQueries.xml
@@ -0,0 +1,38 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog" name="GroupQueries" featureOwner="VXQuery">
+    <GroupInfo>
+        <title>Group by</title>
+        <description/>
+    </GroupInfo>
+    <test-case name="group" FilePath="Groups/" Creator="Christina Pavlopoulou">
+        <description>Group-by query.</description>
+        <query name="group" date="2017-04-20"/>
+        <output-file compare="Text">group.txt</output-file>
+    </test-case>
+    <test-case name="group_json" FilePath="Groups/" Creator="Christina Pavlopoulou">
+        <description>Group-by query in json data.</description>
+        <query name="group_json" date="2017-04-20"/>
+        <output-file compare="Text">group_json.txt</output-file>
+    </test-case>
+    <test-case name="group_json_count" FilePath="Groups/" Creator="Christina Pavlopoulou">
+        <description>Group-by query with aggregation function.</description>
+        <query name="group_json_count" date="2017-04-20"/>
+        <output-file compare="Text">group_json_count.txt</output-file>
+    </test-case>
+</test-group>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/53b86c24/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml
----------------------------------------------------------------------
diff --git a/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml
index 795ab9b..1287225 100644
--- a/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml
+++ b/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml
@@ -75,12 +75,42 @@
       <query name="q14_parser" date="2016-07-12"/>
      <output-file compare="Text">q14_parser.txt</output-file>
    </test-case>
-   <test-case name="json-parser-q15" FilePath="Json/Parser/Partition-2" Creator="Christina Pavlopoulou">
+   <test-case name="json-parser-q14-2" FilePath="Json/Parser/Partition-2" Creator="Christina Pavlopoulou">
+      <description>Parsing a collection of json files.</description>
+      <query name="q14_parser" date="2016-07-12"/>
+     <output-file compare="Text">q14_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q14-4" FilePath="Json/Parser/Partition-4" Creator="Christina Pavlopoulou">
+      <description>Parsing a collection of json files.</description>
+      <query name="q14_parser" date="2016-07-12"/>
+     <output-file compare="Text">q14_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q15" FilePath="Json/Parser/Partition-1" Creator="Christina Pavlopoulou">
+      <description>Parsing a collection of json files.</description>
+      <query name="q15_parser" date="2016-07-15"/>
+     <output-file compare="Text">q15_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q15-2" FilePath="Json/Parser/Partition-2" Creator="Christina Pavlopoulou">
       <description>Parsing a collection of json files.</description>
       <query name="q15_parser" date="2016-07-15"/>
      <output-file compare="Text">q15_parser.txt</output-file>
    </test-case>
-   <test-case name="json-parser-q16" FilePath="Json/Parser/Partition-4" Creator="Christina Pavlopoulou">
+   <test-case name="json-parser-q15-4" FilePath="Json/Parser/Partition-4" Creator="Christina Pavlopoulou">
+      <description>Parsing a collection of json files.</description>
+      <query name="q15_parser" date="2016-07-15"/>
+     <output-file compare="Text">q15_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q16" FilePath="Json/Parser/Partition-1" Creator="Christina Pavlopoulou">
+      <description>Parsing a collection of json files.</description>
+      <query name="q16_parser" date="2016-07-15"/>
+     <output-file compare="Text">q16_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q16-2" FilePath="Json/Parser/Partition-2" Creator="Christina Pavlopoulou">
+      <description>Parsing a collection of json files.</description>
+      <query name="q16_parser" date="2016-07-15"/>
+     <output-file compare="Text">q16_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q16-4" FilePath="Json/Parser/Partition-4" Creator="Christina Pavlopoulou">
       <description>Parsing a collection of json files.</description>
       <query name="q16_parser" date="2016-07-15"/>
      <output-file compare="Text">q16_parser.txt</output-file>


Mime
View raw message