fixed issue 531
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.aql
new file mode 100644
index 0000000..c57f9a0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.aql
@@ -0,0 +1,18 @@
+/**
+ * issue531_string_min_max
+ *
+ * Purpose: test the support of string values for min and max aggregation function
+ * Result: success
+ *
+ */
+
+drop dataverse tempdb if exists;
+create dataverse tempdb;
+use dataverse tempdb;
+
+create type TestType as open{
+id:int32,
+name:string
+}
+
+create dataset t1(TestType) primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.aql
new file mode 100644
index 0000000..9a2a29b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.aql
@@ -0,0 +1,18 @@
+/**
+ * issue531_string_min_max
+ *
+ * Purpose: test the support of string values for min and max aggregation function
+ * Result: success
+ *
+ */
+
+use dataverse tempdb;
+
+insert into dataset t1({"id":5,"name":"Smith"});
+insert into dataset t1({"id":12,"name":"Roger"});
+insert into dataset t1({"id":67,"name":"Kevin"});
+insert into dataset t1({"id":32,"name":"Bob"});
+insert into dataset t1({"id":89,"name":"John"});
+insert into dataset t1({"id":10,"name":"Alex"});
+insert into dataset t1({"id":37,"name":"Calvin"});
+insert into dataset t1({"id":98,"name":"Susan"});
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.aql
new file mode 100644
index 0000000..20e06aa
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.aql
@@ -0,0 +1,13 @@
+/**
+ * issue531_string_min_max
+ *
+ * Purpose: test the support of string values for min and max aggregation function
+ * Result: success
+ *
+ */
+
+use dataverse tempdb;
+
+{"min": min(for $l in dataset t1
+return $l.name), "max": max(for $l in dataset t1
+return $l.name)}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/issue531_string_min_max/issue531_string_min_max.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/issue531_string_min_max/issue531_string_min_max.1.adm
new file mode 100644
index 0000000..9f575f1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/issue531_string_min_max/issue531_string_min_max.1.adm
@@ -0,0 +1 @@
+{ "min": "Alex", "max": "Susan" }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index d099b83..378f2e7 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -15,6 +15,11 @@
<test-suite xmlns="urn:xml.testframework.asterix.ics.uci.edu" ResultOffsetPath="results" QueryOffsetPath="queries" QueryFileExtension=".aql">
<test-group name="aggregate">
<test-case FilePath="aggregate">
+ <compilation-unit name="issue531_string_min_max">
+ <output-dir compare="Text">issue531_string_min_max</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
<compilation-unit name="agg_null">
<output-dir compare="Text">agg_null</output-dir>
</compilation-unit>
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
index 4728f162..24e64fa 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -54,10 +54,11 @@
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedFieldAccessByNameResultType;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedGetItemResultType;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedLocalAvgTypeComputer;
+import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedMinMaxAggTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedNumericAddSubMulDivTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedNumericRoundHalfToEven2TypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedNumericUnaryFunctionTypeComputer;
-import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedSumTypeComputer;
+import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedNumericAggTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedSwitchCaseComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedUnaryMinusTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.NotNullTypeComputer;
@@ -680,10 +681,10 @@
addPrivateFunction(LOCAL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE);
addPrivateFunction(MAKE_FIELD_INDEX_HANDLE, null); // TODO
addPrivateFunction(MAKE_FIELD_NAME_HANDLE, null); // TODO
- addPrivateFunction(MAX, NonTaggedSumTypeComputer.INSTANCE);
- addPrivateFunction(LOCAL_MAX, NonTaggedSumTypeComputer.INSTANCE);
- addPrivateFunction(MIN, NonTaggedSumTypeComputer.INSTANCE);
- addPrivateFunction(LOCAL_MIN, NonTaggedSumTypeComputer.INSTANCE);
+ addPrivateFunction(MAX, NonTaggedMinMaxAggTypeComputer.INSTANCE);
+ addPrivateFunction(LOCAL_MAX, NonTaggedMinMaxAggTypeComputer.INSTANCE);
+ addPrivateFunction(MIN, NonTaggedMinMaxAggTypeComputer.INSTANCE);
+ addPrivateFunction(LOCAL_MIN, NonTaggedMinMaxAggTypeComputer.INSTANCE);
addPrivateFunction(NON_EMPTY_STREAM, ABooleanTypeComputer.INSTANCE);
addFunction(NULL_CONSTRUCTOR, ANullTypeComputer.INSTANCE);
addFunction(NUMERIC_UNARY_MINUS, NonTaggedUnaryMinusTypeComputer.INSTANCE);
@@ -739,8 +740,8 @@
addPrivateFunction(SERIAL_COUNT, AInt64TypeComputer.INSTANCE);
addPrivateFunction(SERIAL_GLOBAL_AVG, OptionalADoubleTypeComputer.INSTANCE);
addPrivateFunction(SERIAL_LOCAL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE);
- addPrivateFunction(SERIAL_SUM, NonTaggedSumTypeComputer.INSTANCE);
- addPrivateFunction(SERIAL_LOCAL_SUM, NonTaggedSumTypeComputer.INSTANCE);
+ addPrivateFunction(SERIAL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE);
+ addPrivateFunction(SERIAL_LOCAL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE);
addFunction(SIMILARITY_JACCARD, AFloatTypeComputer.INSTANCE);
addFunction(SIMILARITY_JACCARD_CHECK, OrderedListOfAnyTypeComputer.INSTANCE);
addPrivateFunction(SIMILARITY_JACCARD_SORTED, AFloatTypeComputer.INSTANCE);
@@ -796,8 +797,8 @@
}
});
addFunction(SUBSTRING, SubstringTypeComputer.INSTANCE);
- addPrivateFunction(SUM, NonTaggedSumTypeComputer.INSTANCE);
- addPrivateFunction(LOCAL_SUM, NonTaggedSumTypeComputer.INSTANCE);
+ addPrivateFunction(SUM, NonTaggedNumericAggTypeComputer.INSTANCE);
+ addPrivateFunction(LOCAL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE);
addFunction(SWITCH_CASE, NonTaggedSwitchCaseComputer.INSTANCE);
addPrivateFunction(REG_EXP, ABooleanTypeComputer.INSTANCE);
addFunction(INJECT_FAILURE, InjectFailureTypeComputer.INSTANCE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedSumTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
similarity index 88%
copy from asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedSumTypeComputer.java
copy to asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
index 2437da4..a6c39b6 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedSumTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
@@ -30,13 +30,12 @@
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class NonTaggedSumTypeComputer implements IResultTypeComputer {
+public class NonTaggedMinMaxAggTypeComputer implements IResultTypeComputer {
+ private static final String errMsg = "Aggregator is not implemented for ";
- private static final String errMsg = "Sum aggregator is not implemented for ";
+ public static final NonTaggedMinMaxAggTypeComputer INSTANCE = new NonTaggedMinMaxAggTypeComputer();
- public static final NonTaggedSumTypeComputer INSTANCE = new NonTaggedSumTypeComputer();
-
- private NonTaggedSumTypeComputer() {
+ private NonTaggedMinMaxAggTypeComputer() {
}
@Override
@@ -79,6 +78,9 @@
case INT8:
unionList.add(BuiltinType.AINT8);
break;
+ case STRING:
+ unionList.add(BuiltinType.ASTRING);
+ break;
case ANY:
return BuiltinType.ANY;
default: {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedSumTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
similarity index 91%
rename from asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedSumTypeComputer.java
rename to asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
index 2437da4..7582785 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedSumTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
@@ -30,13 +30,13 @@
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class NonTaggedSumTypeComputer implements IResultTypeComputer {
+public class NonTaggedNumericAggTypeComputer implements IResultTypeComputer {
- private static final String errMsg = "Sum aggregator is not implemented for ";
+ private static final String errMsg = "Aggregator is not implemented for ";
- public static final NonTaggedSumTypeComputer INSTANCE = new NonTaggedSumTypeComputer();
+ public static final NonTaggedNumericAggTypeComputer INSTANCE = new NonTaggedNumericAggTypeComputer();
- private NonTaggedSumTypeComputer() {
+ private NonTaggedNumericAggTypeComputer() {
}
@Override