Yingyi Bu has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/1257
Change subject: Add type check functions, including:
......................................................................
Add type check functions, including:
-isboolean
-isnumber
-isstring
-isarray
-isobject
Change-Id: Id12067dbd89f74a6c1248eb7ac6504400a67cbf6
---
M
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isarray/isarray.1.query.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isboolean/isboolean.1.query.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isnumber/isnumber.1.query.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isobject/isobject.1.query.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isstring/isstring.1.query.sqlpp
A
asterixdb/asterix-app/src/test/resources/runtimets/results/types/isarray/isarray.1.adm
A
asterixdb/asterix-app/src/test/resources/runtimets/results/types/isboolean/isboolean.1.adm
A
asterixdb/asterix-app/src/test/resources/runtimets/results/types/isnumber/isnumber.1.adm
A
asterixdb/asterix-app/src/test/resources/runtimets/results/types/isobject/isobject.1.adm
A
asterixdb/asterix-app/src/test/resources/runtimets/results/types/isstring/isstring.1.adm
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
M
asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
M
asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
A
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsArrayDescriptor.java
A
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsBooleanDescriptor.java
A
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNumberDescriptor.java
A
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsObjectDescriptor.java
A
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsStringDescriptor.java
19 files changed, 556 insertions(+), 0 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/57/1257/1
diff --git
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
index 2482121..dd45c86 100644
---
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
+++
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
@@ -157,8 +157,13 @@
import
org.apache.asterix.runtime.evaluators.functions.HashedGramTokensDescriptor;
import
org.apache.asterix.runtime.evaluators.functions.HashedWordTokensDescriptor;
import org.apache.asterix.runtime.evaluators.functions.InjectFailureDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsArrayDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsBooleanDescriptor;
import org.apache.asterix.runtime.evaluators.functions.IsMissingDescriptor;
import org.apache.asterix.runtime.evaluators.functions.IsNullDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsNumberDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsObjectDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsStringDescriptor;
import org.apache.asterix.runtime.evaluators.functions.IsSystemNullDescriptor;
import org.apache.asterix.runtime.evaluators.functions.IsUnknownDescriptor;
import org.apache.asterix.runtime.evaluators.functions.LenDescriptor;
@@ -666,6 +671,13 @@
functionsToInjectUnkownHandling.add(GetOverlappingIntervalDescriptor.FACTORY);
functionsToInjectUnkownHandling.add(DurationFromIntervalDescriptor.FACTORY);
+ // Type functions.
+ functionsToInjectUnkownHandling.add(IsBooleanDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IsNumberDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IsStringDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IsArrayDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IsObjectDescriptor.FACTORY);
+
// Cast function
functionsToInjectUnkownHandling.add(CastTypeDescriptor.FACTORY);
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isarray/isarray.1.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isarray/isarray.1.query.sqlpp
new file mode 100644
index 0000000..4ea86f7
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isarray/isarray.1.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+{
+ "a": isarray(true),
+ "b": isarray(false),
+ "c": isarray(null),
+ "d": isarray(missing),
+ "e": isarray("d"),
+ "f": isarray(4.0),
+ "g": isarray(5),
+ "h": isarray(["1", 2]),
+ "i": isarray({"a":1})
+};
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isboolean/isboolean.1.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isboolean/isboolean.1.query.sqlpp
new file mode 100644
index 0000000..5a10b87
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isboolean/isboolean.1.query.sqlpp
@@ -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.
+ */
+
+{
+ "a": isboolean(true),
+ "b": isboolean(false),
+ "c": isbool(null),
+ "d": isbool(missing),
+ "e": isbool("d")
+};
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isnumber/isnumber.1.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isnumber/isnumber.1.query.sqlpp
new file mode 100644
index 0000000..5a813fb
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isnumber/isnumber.1.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+{
+ "a": isnumber(true),
+ "b": isnumber(false),
+ "c": isnumber(null),
+ "d": isnumber(missing),
+ "e": isnumber("d"),
+ "f": isnumber(4.0),
+ "g": isnumber(5)
+};
+
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isobject/isobject.1.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isobject/isobject.1.query.sqlpp
new file mode 100644
index 0000000..8e1668a
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isobject/isobject.1.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+{
+ "a": isobject(true),
+ "b": isobject(false),
+ "c": isobject(null),
+ "d": isobject(missing),
+ "e": isobj("d"),
+ "f": isobj(4.0),
+ "g": isobj(5),
+ "h": isobj(["1", 2]),
+ "i": isobj({"a":1})
+};
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isstring/isstring.1.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isstring/isstring.1.query.sqlpp
new file mode 100644
index 0000000..a7193e1
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/types/isstring/isstring.1.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+{
+ "a": isstring(true),
+ "b": isstring(false),
+ "c": isstring(null),
+ "d": isstr(missing),
+ "e": isstr("d"),
+ "f": isstr(4.0),
+ "g": isstr(5)
+};
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isarray/isarray.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isarray/isarray.1.adm
new file mode 100644
index 0000000..b97271c
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isarray/isarray.1.adm
@@ -0,0 +1 @@
+{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h":
true, "i": false }
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isboolean/isboolean.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isboolean/isboolean.1.adm
new file mode 100644
index 0000000..1e57b46
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isboolean/isboolean.1.adm
@@ -0,0 +1 @@
+{ "a": true, "b": true, "c": null, "e": false }
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isnumber/isnumber.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isnumber/isnumber.1.adm
new file mode 100644
index 0000000..7c4ae08
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isnumber/isnumber.1.adm
@@ -0,0 +1 @@
+{ "a": false, "b": false, "c": null, "e": false, "f": true, "g": true }
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isobject/isobject.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isobject/isobject.1.adm
new file mode 100644
index 0000000..7b29632
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isobject/isobject.1.adm
@@ -0,0 +1 @@
+{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h":
false, "i": true }
\ No newline at end of file
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isstring/isstring.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isstring/isstring.1.adm
new file mode 100644
index 0000000..e10841e
--- /dev/null
+++
b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/isstring/isstring.1.adm
@@ -0,0 +1 @@
+{ "a": false, "b": false, "c": null, "e": true, "f": false, "g": false }
diff --git
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 38ef4c2..48fa1cd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -7921,6 +7921,31 @@
</compilation-unit>
</test-case>
<test-case FilePath="types">
+ <compilation-unit name="isarray">
+ <output-dir compare="Text">isarray</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="types">
+ <compilation-unit name="isboolean">
+ <output-dir compare="Text">isboolean</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="types">
+ <compilation-unit name="isnumber">
+ <output-dir compare="Text">isnumber</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="types">
+ <compilation-unit name="isobject">
+ <output-dir compare="Text">isobject</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="types">
+ <compilation-unit name="isstring">
+ <output-dir compare="Text">isstring</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="types">
<compilation-unit name="record01">
<output-dir compare="Text">record01</output-dir>
</compilation-unit>
diff --git
a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
index 1f7e4b0..c2102bc 100644
---
a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
+++
b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/CommonFunctionMapUtil.java
@@ -48,6 +48,17 @@
FUNCTION_NAME_MAP.put("smallint", "int16"); // smallint, internal:
int16
FUNCTION_NAME_MAP.put("integer", "int32"); // integer, internal: int32
FUNCTION_NAME_MAP.put("bigint", "int64"); // bigint, internal: int64
+
+ // Type functions.
+ FUNCTION_NAME_MAP.put("isboolean", "is-boolean"); // isboolean,
internal: is-boolean
+ FUNCTION_NAME_MAP.put("isbool", "is-boolean"); // isboolean, internal:
is-boolean
+ FUNCTION_NAME_MAP.put("isnumber", "is-number"); // isnumber, internal:
is-number
+ FUNCTION_NAME_MAP.put("isnum", "is-number"); // isnum, internal:
is-number
+ FUNCTION_NAME_MAP.put("isstring", "is-string"); // isstring, internal:
is-string
+ FUNCTION_NAME_MAP.put("isstr", "is-string"); // isstr, internal:
is-string
+ FUNCTION_NAME_MAP.put("isarray", "is-array"); // isarray, internal:
is-array
+ FUNCTION_NAME_MAP.put("isobject", "is-object"); // isobject, internal:
is-object
+ FUNCTION_NAME_MAP.put("isobj", "is-object"); // isobj, internal:
is-object
}
private CommonFunctionMapUtil() {
diff --git
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
index a85d33b..80f13d6 100644
---
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
+++
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -761,6 +761,16 @@
public static final FunctionIdentifier IS_NULL =
AlgebricksBuiltinFunctions.IS_NULL;
public static final FunctionIdentifier IS_UNKOWN = new
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"is-unknown", 1);
+ public static final FunctionIdentifier IS_BOOLEAN = new
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+ "is-boolean", 1);
+ public static final FunctionIdentifier IS_NUMBER = new
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "is-number",
+ 1);
+ public static final FunctionIdentifier IS_STRING = new
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "is-string",
+ 1);
+ public static final FunctionIdentifier IS_ARRAY = new
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "is-array",
+ 1);
+ public static final FunctionIdentifier IS_OBJECT = new
FunctionIdentifier(FunctionConstants.ASTERIX_NS, "is-object",
+ 1);
public static final FunctionIdentifier IS_SYSTEM_NULL = new
FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"is-system-null", 1);
@@ -794,6 +804,11 @@
addFunction(IS_NULL, BooleanOnlyTypeComputer.INSTANCE, true);
addFunction(IS_UNKOWN, BooleanOnlyTypeComputer.INSTANCE, true);
addFunction(IS_SYSTEM_NULL, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_BOOLEAN, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_NUMBER, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_STRING, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_ARRAY, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_OBJECT, BooleanOnlyTypeComputer.INSTANCE, true);
addFunction(NOT, BooleanFunctionTypeComputer.INSTANCE, true);
addPrivateFunction(EQ, BooleanFunctionTypeComputer.INSTANCE, true);
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsArrayDescriptor.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsArrayDescriptor.java
new file mode 100644
index 0000000..c8cb313
--- /dev/null
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsArrayDescriptor.java
@@ -0,0 +1,68 @@
+/*
+ * 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.asterix.runtime.evaluators.functions;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import
org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class IsArrayDescriptor extends AbstractScalarFunctionDynamicDescriptor
{
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new
IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new IsArrayDescriptor();
+ }
+ };
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(final
IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(final
IHyracksTaskContext ctx) throws AlgebricksException {
+ final IScalarEvaluator eval =
args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
+
+ @Override
+ protected Value isMatch(byte typeTag) {
+ return typeTag ==
ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG ? Value.TRUE : Value.FALSE;
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.IS_ARRAY;
+ }
+
+}
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsBooleanDescriptor.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsBooleanDescriptor.java
new file mode 100644
index 0000000..89318bd
--- /dev/null
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsBooleanDescriptor.java
@@ -0,0 +1,68 @@
+/*
+ * 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.asterix.runtime.evaluators.functions;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import
org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class IsBooleanDescriptor extends
AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new
IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new IsBooleanDescriptor();
+ }
+ };
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(final
IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(final
IHyracksTaskContext ctx) throws AlgebricksException {
+ final IScalarEvaluator eval =
args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
+
+ @Override
+ protected Value isMatch(byte typeTag) {
+ return typeTag == ATypeTag.SERIALIZED_BOOLEAN_TYPE_TAG
? Value.TRUE : Value.FALSE;
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.IS_BOOLEAN;
+ }
+
+}
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNumberDescriptor.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNumberDescriptor.java
new file mode 100644
index 0000000..418d778
--- /dev/null
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNumberDescriptor.java
@@ -0,0 +1,73 @@
+/*
+ * 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.asterix.runtime.evaluators.functions;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import
org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class IsNumberDescriptor extends
AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new
IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new IsNumberDescriptor();
+ }
+ };
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(final
IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(final
IHyracksTaskContext ctx) throws AlgebricksException {
+ final IScalarEvaluator eval =
args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
+
+ @Override
+ protected Value isMatch(byte typeTag) {
+ return typeTag == ATypeTag.SERIALIZED_INT8_TYPE_TAG
+ || typeTag ==
ATypeTag.SERIALIZED_INT16_TYPE_TAG
+ || typeTag ==
ATypeTag.SERIALIZED_INT32_TYPE_TAG
+ || typeTag ==
ATypeTag.SERIALIZED_INT64_TYPE_TAG
+ || typeTag ==
ATypeTag.SERIALIZED_FLOAT_TYPE_TAG
+ || typeTag ==
ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG ? Value.TRUE : Value.FALSE;
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.IS_NUMBER;
+ }
+
+}
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsObjectDescriptor.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsObjectDescriptor.java
new file mode 100644
index 0000000..5a3f2d3
--- /dev/null
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsObjectDescriptor.java
@@ -0,0 +1,68 @@
+/*
+ * 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.asterix.runtime.evaluators.functions;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import
org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class IsObjectDescriptor extends
AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new
IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new IsObjectDescriptor();
+ }
+ };
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(final
IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(final
IHyracksTaskContext ctx) throws AlgebricksException {
+ final IScalarEvaluator eval =
args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
+
+ @Override
+ protected Value isMatch(byte typeTag) {
+ return typeTag == ATypeTag.SERIALIZED_RECORD_TYPE_TAG
? Value.TRUE : Value.FALSE;
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.IS_OBJECT;
+ }
+
+}
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsStringDescriptor.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsStringDescriptor.java
new file mode 100644
index 0000000..44c5a6c
--- /dev/null
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsStringDescriptor.java
@@ -0,0 +1,68 @@
+/*
+ * 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.asterix.runtime.evaluators.functions;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import
org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class IsStringDescriptor extends
AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new
IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new IsStringDescriptor();
+ }
+ };
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(final
IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(final
IHyracksTaskContext ctx) throws AlgebricksException {
+ final IScalarEvaluator eval =
args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
+
+ @Override
+ protected Value isMatch(byte typeTag) {
+ return typeTag == ATypeTag.SERIALIZED_STRING_TYPE_TAG
? Value.TRUE : Value.FALSE;
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.IS_STRING;
+ }
+
+}
--
To view, visit https://asterix-gerrit.ics.uci.edu/1257
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id12067dbd89f74a6c1248eb7ac6504400a67cbf6
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Yingyi Bu <[email protected]>