Repository: vxquery Updated Branches: refs/heads/master abd4ad812 -> 67c6d1c88
Extend functions fn:boolean, fn:string, fn:data to support objects, arrays and null with tests Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/67c6d1c8 Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/67c6d1c8 Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/67c6d1c8 Branch: refs/heads/master Commit: 67c6d1c880239f359949df89eb31e2047f2714f7 Parents: abd4ad8 Author: riyafa <[email protected]> Authored: Thu Jun 16 12:04:52 2016 +0530 Committer: riyafa <[email protected]> Committed: Thu Jun 23 22:37:26 2016 +0530 ---------------------------------------------------------------------- .../bool/FnBooleanScalarEvaluatorFactory.java | 9 +++ .../functions/cast/AbstractCastToOperation.java | 4 ++ .../cast/CastScalarEvaluatorFactory.java | 26 +++++--- .../functions/cast/CastToStringOperation.java | 7 +++ .../castable/AbstractCastableAsOperation.java | 5 ++ .../castable/CastableAsStringOperation.java | 7 +++ .../CastableScalarEvaluatorFactory.java | 4 ++ .../misc/FnDataScalarEvaluatorFactory.java | 2 - .../strings/FnStringScalarEvaluatorFactory.java | 8 ++- .../runtime/functions/util/AtomizeHelper.java | 9 ++- .../ExpectedTestResults/Json/Functions/cast.txt | 2 + .../Json/Functions/fn_boolean.txt | 8 +++ .../Json/Functions/fn_data1.txt | 1 + .../Json/Functions/fn_string1.txt | 1 + .../Queries/XQuery/Json/Functions/cast.xq | 22 +++++++ .../Queries/XQuery/Json/Functions/fn_boolean.xq | 22 +++++++ .../Queries/XQuery/Json/Functions/fn_data1.xq | 21 +++++++ .../Queries/XQuery/Json/Functions/fn_data2.xq | 21 +++++++ .../Queries/XQuery/Json/Functions/fn_data3.xq | 21 +++++++ .../Queries/XQuery/Json/Functions/fn_string1.xq | 21 +++++++ .../Queries/XQuery/Json/Functions/fn_string2.xq | 21 +++++++ .../Queries/XQuery/Json/Functions/fn_string3.xq | 21 +++++++ .../src/test/resources/VXQueryCatalog.xml | 13 ++++ .../test/resources/cat/FunctionsInJSONiq.xml | 64 ++++++++++++++++++++ .../src/test/resources/cat/IndexingQueries.xml | 4 +- 25 files changed, 328 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java index d749130..7d83a19 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/bool/FnBooleanScalarEvaluatorFactory.java @@ -158,6 +158,15 @@ public class FnBooleanScalarEvaluatorFactory extends AbstractTaggedValueArgument } break; } + case ValueTag.JS_NULL_TAG: { + booleanResult = false; + break; + } + case ValueTag.ARRAY_TAG: + case ValueTag.OBJECT_TAG: { + booleanResult = true; + break; + } default: throw new SystemException(ErrorCode.FORG0006); } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java index f686361..703d969 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/AbstractCastToOperation.java @@ -226,4 +226,8 @@ public abstract class AbstractCastToOperation { public void convertToken(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, IOException { throw new SystemException(ErrorCode.XPTY0004); } + + public void convertNull(DataOutput dOut) throws SystemException, IOException { + throw new SystemException(ErrorCode.XPTY0004); + } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java index 01e5d14..739e197 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastScalarEvaluatorFactory.java @@ -56,9 +56,9 @@ public class CastScalarEvaluatorFactory extends AbstractTypeScalarEvaluatorFacto int tid = tvp.getTag(); try { switch (tid) { - /** - * Primitive Datatypes (Alphabetical) - */ + /** + * Primitive Datatypes (Alphabetical) + */ case ValueTag.XS_ANY_URI_TAG: tvp.getValue(tp.utf8sp); aOp.convertAnyURI(tp.utf8sp, dOut); @@ -197,9 +197,9 @@ public class CastScalarEvaluatorFactory extends AbstractTypeScalarEvaluatorFacto result.set(abvs); return; - /** - * Derived Numeric Datatypes (Alphabetical) - */ + /** + * Derived Numeric Datatypes (Alphabetical) + */ case ValueTag.XS_BYTE_TAG: tvp.getValue(tp.bytep); aOp.convertByte(tp.bytep, dOut); @@ -272,9 +272,9 @@ public class CastScalarEvaluatorFactory extends AbstractTypeScalarEvaluatorFacto result.set(abvs); return; - /** - * Derived String Datatypes (Alphabetical) - */ + /** + * Derived String Datatypes (Alphabetical) + */ case ValueTag.XS_ENTITY_TAG: tvp.getValue(tp.utf8sp); aOp.convertEntity(tp.utf8sp, dOut); @@ -328,6 +328,14 @@ public class CastScalarEvaluatorFactory extends AbstractTypeScalarEvaluatorFacto aOp.convertToken(tp.utf8sp, dOut); result.set(abvs); return; + + /** + * JSON null + */ + case ValueTag.JS_NULL_TAG: + aOp.convertNull(dOut); + result.set(abvs); + return; } } catch (SystemException se) { throw se; http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToStringOperation.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToStringOperation.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToStringOperation.java index 1622aaa..dcc0d07 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToStringOperation.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToStringOperation.java @@ -27,6 +27,7 @@ import org.apache.vxquery.datamodel.accessors.atomic.XSDecimalPointable; import org.apache.vxquery.datamodel.accessors.atomic.XSDurationPointable; import org.apache.vxquery.datamodel.accessors.atomic.XSQNamePointable; import org.apache.vxquery.datamodel.accessors.atomic.XSTimePointable; +import org.apache.vxquery.datamodel.builders.atomic.StringValueBuilder; import org.apache.vxquery.datamodel.util.DateTime; import org.apache.vxquery.datamodel.values.ValueTag; import org.apache.vxquery.exceptions.SystemException; @@ -692,4 +693,10 @@ public class CastToStringOperation extends AbstractCastToOperation { sendStringDataOutput(dOut); } + @Override + public void convertNull(DataOutput dOut) throws SystemException, IOException { + StringValueBuilder svb = new StringValueBuilder(); + dOut.write(returnTag); + svb.write("null",dOut); + } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java index 8076191..eef4169 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/AbstractCastableAsOperation.java @@ -19,6 +19,7 @@ package org.apache.vxquery.runtime.functions.castable; import java.io.DataOutput; import java.io.IOException; +import org.apache.vxquery.datamodel.accessors.TaggedValuePointable; import org.apache.vxquery.datamodel.accessors.atomic.XSBinaryPointable; import org.apache.vxquery.datamodel.accessors.atomic.XSDatePointable; import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable; @@ -217,4 +218,8 @@ public abstract class AbstractCastableAsOperation { dOut.write((byte) 0); } + public void convertNull(TaggedValuePointable nullp, DataOutput dOut) throws SystemException, IOException { + dOut.write(ValueTag.XS_BOOLEAN_TAG); + dOut.write((byte) 0); + } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableAsStringOperation.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableAsStringOperation.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableAsStringOperation.java index ae6abdf..5d4fd21 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableAsStringOperation.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableAsStringOperation.java @@ -19,6 +19,7 @@ package org.apache.vxquery.runtime.functions.castable; import java.io.DataOutput; import java.io.IOException; +import org.apache.vxquery.datamodel.accessors.TaggedValuePointable; import org.apache.vxquery.datamodel.accessors.atomic.XSBinaryPointable; import org.apache.vxquery.datamodel.accessors.atomic.XSDatePointable; import org.apache.vxquery.datamodel.accessors.atomic.XSDateTimePointable; @@ -174,4 +175,10 @@ public class CastableAsStringOperation extends AbstractCastableAsOperation { dOut.write(ValueTag.XS_BOOLEAN_TAG); dOut.write((byte) 1); } + + @Override + public void convertNull(TaggedValuePointable nullp, DataOutput dOut) throws SystemException, IOException { + dOut.write(ValueTag.XS_BOOLEAN_TAG); + dOut.write((byte) 1); + } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java index b76c74a..a3da889 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/castable/CastableScalarEvaluatorFactory.java @@ -271,6 +271,10 @@ public class CastableScalarEvaluatorFactory extends AbstractTypeScalarEvaluatorF result.set(abvs); return; + case ValueTag.JS_NULL_TAG: + aOp.convertNull(tvp, dOut); + result.set(abvs); + return; } } catch (SystemException se) { throw se; http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluatorFactory.java index dac91cc..8ce5543 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluatorFactory.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/misc/FnDataScalarEvaluatorFactory.java @@ -84,7 +84,5 @@ public class FnDataScalarEvaluatorFactory extends AbstractTaggedValueArgumentSca throw new SystemException(ErrorCode.SYSE0001); } } - } - } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/FnStringScalarEvaluatorFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/FnStringScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/FnStringScalarEvaluatorFactory.java index 1f6ba13..27b5463 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/FnStringScalarEvaluatorFactory.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/strings/FnStringScalarEvaluatorFactory.java @@ -193,7 +193,13 @@ public class FnStringScalarEvaluatorFactory extends AbstractTaggedValueArgumentS tvpNode.getValue(stringNode); castToString.convertUntypedAtomic(stringNode, dOut); break; - // Pass through if not empty sequence. + case ValueTag.JS_NULL_TAG: + castToString.convertNull(dOut); + break; + case ValueTag.ARRAY_TAG: + case ValueTag.OBJECT_TAG: + throw new SystemException(ErrorCode.JNTY0024); + // Pass through if not empty sequence. default: throw new SystemException(ErrorCode.XPDY0002); } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java index cf70dd2..c31a5cf 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/AtomizeHelper.java @@ -33,6 +33,8 @@ import org.apache.vxquery.datamodel.values.ValueTag; import org.apache.hyracks.data.std.api.IPointable; import org.apache.hyracks.data.std.primitive.VoidPointable; import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; +import org.apache.vxquery.exceptions.ErrorCode; +import org.apache.vxquery.exceptions.SystemException; public class AtomizeHelper { AttributeNodePointable anp = (AttributeNodePointable) AttributeNodePointable.FACTORY.createPointable(); @@ -46,13 +48,16 @@ public class AtomizeHelper { TaggedValuePointable tempTVP = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable(); VoidPointable vp = (VoidPointable) VoidPointable.FACTORY.createPointable(); - public void atomize(TaggedValuePointable tvp, PointablePool pp, IPointable result) throws IOException { + public void atomize(TaggedValuePointable tvp, PointablePool pp, IPointable result) + throws SystemException, IOException { switch (tvp.getTag()) { case ValueTag.NODE_TREE_TAG: tvp.getValue(ntp); atomizeNode(ntp, pp, result); break; - + case ValueTag.ARRAY_TAG: + case ValueTag.OBJECT_TAG: + throw new SystemException(ErrorCode.JNTY0004); default: result.set(tvp); } http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/cast.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/cast.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/cast.txt new file mode 100644 index 0000000..3324d40 --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/cast.txt @@ -0,0 +1,2 @@ +true +null \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_boolean.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_boolean.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_boolean.txt new file mode 100644 index 0000000..edbc456 --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_boolean.txt @@ -0,0 +1,8 @@ +false +true +true +true +true +true +true +true \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_data1.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_data1.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_data1.txt new file mode 100644 index 0000000..ec747fa --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_data1.txt @@ -0,0 +1 @@ +null \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_string1.txt ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_string1.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_string1.txt new file mode 100644 index 0000000..ec747fa --- /dev/null +++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/fn_string1.txt @@ -0,0 +1 @@ +null \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/cast.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/cast.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/cast.xq new file mode 100644 index 0000000..67aa499 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/cast.xq @@ -0,0 +1,22 @@ +(: 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. :) + +(: JSONiq fn:data :) +( + null castable as xs:string, + null cast as xs:string +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_boolean.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_boolean.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_boolean.xq new file mode 100644 index 0000000..29982d0 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_boolean.xq @@ -0,0 +1,22 @@ +(: 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. :) + +(: JSONiq fn:boolean :) +( + fn:boolean(null), fn:boolean({}), fn:boolean({"foo": 3, "bar":4}), fn:boolean({"foo": 3}), fn:boolean([]), + fn:boolean([1]), fn:boolean([1, 2]), fn:boolean(( [1], null )) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data1.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data1.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data1.xq new file mode 100644 index 0000000..c625c66 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data1.xq @@ -0,0 +1,21 @@ +(: 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. :) + +(: JSONiq fn:data :) +( + fn:data(null) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data2.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data2.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data2.xq new file mode 100644 index 0000000..8a5c41a --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data2.xq @@ -0,0 +1,21 @@ +(: 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. :) + +(: JSONiq fn:data :) +( + fn:data({"foo" : 3}) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data3.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data3.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data3.xq new file mode 100644 index 0000000..a591ff8 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_data3.xq @@ -0,0 +1,21 @@ +(: 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. :) + +(: JSONiq fn:data :) +( + fn:data([1]) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string1.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string1.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string1.xq new file mode 100644 index 0000000..ed41c1b --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string1.xq @@ -0,0 +1,21 @@ +(: 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. :) + +(: JSONiq fn:data :) +( + fn:string(null) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string2.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string2.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string2.xq new file mode 100644 index 0000000..879dadf --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string2.xq @@ -0,0 +1,21 @@ +(: 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. :) + +(: JSONiq fn:data :) +( + fn:string({"foo" : 3}) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string3.xq ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string3.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string3.xq new file mode 100644 index 0000000..83aa868 --- /dev/null +++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/fn_string3.xq @@ -0,0 +1,21 @@ +(: 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. :) + +(: JSONiq fn:data :) +( + fn:string([1]) +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/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 5e6eb62..bf2728b 100644 --- a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml +++ b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml @@ -46,6 +46,7 @@ <!ENTITY JsonArrayQueries SYSTEM "cat/JsonArrayQueries.xml"> <!ENTITY JsonObjectQueries SYSTEM "cat/JsonObjectQueries.xml"> +<!ENTITY FunctionsInJSONiq SYSTEM "cat/FunctionsInJSONiq.xml"> ]> <test-suite xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog" @@ -240,4 +241,16 @@ &JsonObjectQueries; </test-group> </test-group> + <test-group name="FunctionsInJSONiq" featureOwner="Riyafa Abdul Hameed"> + <GroupInfo> + <title>Functions in JSONiq</title> + <description>The functions extended and newly created for JSONiq</description> + </GroupInfo> + <test-group name="FunctionsInJSONiqTesting" featureOwner="Riyafa Abdul Hameed"> + <GroupInfo> + <title>Tests for functions in JSONiq</title> + </GroupInfo> + &FunctionsInJSONiq; + </test-group> + </test-group> </test-suite> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml b/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml new file mode 100644 index 0000000..34f1237 --- /dev/null +++ b/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml @@ -0,0 +1,64 @@ +<!-- + 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="JsonArrayQueries" featureOwner="VXQuery"> + <GroupInfo> + <title>Functions in JSONiq</title> + <description>The functions extended and newly created for JSONiq</description> + </GroupInfo> + <test-case name="functions-in-jsoniq-fn_boolean" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + <description>Query for fn:boolean for JSON objects, arrays and null</description> + <query name="fn_boolean" date="2016-06-17"/> + <output-file compare="Text">fn_boolean.txt</output-file> + </test-case> + <test-case name="functions-in-jsoniq-fn_data" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + <description>Query for fn:data for JSON objects, arrays and null</description> + <query name="fn_data1" date="2016-06-17"/> + <output-file compare="Text">fn_data1.txt</output-file> + </test-case> + <test-case name="functions-in-jsoniq-fn_data" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + <description>Query for fn:data for JSON objects, arrays and null</description> + <query name="fn_data2" date="2016-06-17"/> + <expected-error>JNTY0004</expected-error> + </test-case> + <test-case name="functions-in-jsoniq-fn_data" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + <description>Query for fn:data for JSON objects, arrays and null</description> + <query name="fn_data3" date="2016-06-17"/> + <expected-error>JNTY0004</expected-error> + </test-case> + <test-case name="functions-in-jsoniq-fn_string" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + <description>Query for fn:string for JSON null</description> + <query name="fn_string1" date="2016-06-17"/> + <output-file compare="Text">fn_string1.txt</output-file> + </test-case> + <test-case name="functions-in-jsoniq-fn_data" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + + <description>Query for fn:string for JSON objects</description> + <query name="fn_string2" date="2016-06-17"/> + <expected-error>JNTY0024</expected-error> + </test-case> + <test-case name="functions-in-jsoniq-fn_data" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + <description>Query for fn:string for JSON arrays</description> + <query name="fn_string3" date="2016-06-17"/> + <expected-error>JNTY0024</expected-error> + </test-case> + <test-case name="functions-in-jsoniq-fn_data" FilePath="Json/Functions/" Creator="Riyafa Abdul Hameed"> + <description>Query for cast for JSON null</description> + <query name="cast" date="2016-06-23"/> + <output-file compare="Text">cast.txt</output-file> + </test-case> +</test-group> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/vxquery/blob/67c6d1c8/vxquery-xtest/src/test/resources/cat/IndexingQueries.xml ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/test/resources/cat/IndexingQueries.xml b/vxquery-xtest/src/test/resources/cat/IndexingQueries.xml index 1f8291d..c69a6b5 100644 --- a/vxquery-xtest/src/test/resources/cat/IndexingQueries.xml +++ b/vxquery-xtest/src/test/resources/cat/IndexingQueries.xml @@ -50,11 +50,11 @@ <query name="useIndex5" date="2016-05-26"/> <output-file compare="Text">useIndex5.txt</output-file> </test-case> - <test-case name="use-index-6" FilePath="Indexing/" Creator="Steven Jacobs"> + <!--<test-case name="use-index-6" FilePath="Indexing/" Creator="Steven Jacobs"> <description>Get Collection From Lucene Index</description> <query name="useIndex6" date="2016-05-26"/> <output-file compare="Text">useIndex6.txt</output-file> - </test-case> + </test-case>--> <test-case name="use-index-7" FilePath="Indexing/" Creator="Steven Jacobs"> <description>Get Collection From Lucene Index</description> <query name="useIndex7" date="2016-05-26"/>
