added interval-bin function with test cases for issue 546
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.1.ddl.aql
deleted file mode 100644
index 754ea81..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.1.ddl.aql
+++ /dev/null
@@ -1,3 +0,0 @@
-drop dataverse test if exists;
-create dataverse test;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.2.update.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.2.update.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.3.query.aql
deleted file mode 100644
index 169ca39..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_double_01/unary-minus_double_01.3.query.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse test;
-
-let $c1 := double("-20.56e-30")
-let $c2 := double("NaN")
-let $c3 := double("INF")
-let $c4 := double("-INF")
-return {"double1": numeric-unary-minus($c1),"double2": numeric-unary-minus($c2),"double3": numeric-unary-minus($c3),"double4": numeric-unary-minus($c4)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.1.ddl.aql
deleted file mode 100644
index 754ea81..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.1.ddl.aql
+++ /dev/null
@@ -1,3 +0,0 @@
-drop dataverse test if exists;
-create dataverse test;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.2.update.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.2.update.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.3.query.aql
deleted file mode 100644
index e5e0071..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_float_01/unary-minus_float_01.3.query.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse test;
-
-let $c1 := float("-80.20f")
-let $c2 := float("NaN")
-let $c3 := float("INF")
-let $c4 := float("-INF")
-return {"float1": numeric-unary-minus($c1),"float2": numeric-unary-minus($c2),"float3": numeric-unary-minus($c3),"float4": numeric-unary-minus($c4)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.1.ddl.aql
deleted file mode 100644
index 754ea81..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.1.ddl.aql
+++ /dev/null
@@ -1,3 +0,0 @@
-drop dataverse test if exists;
-create dataverse test;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.2.update.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.2.update.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.3.query.aql
deleted file mode 100644
index 660e55f..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/numeric/unary-minus_int_01/unary-minus_int_01.3.query.aql
+++ /dev/null
@@ -1,7 +0,0 @@
-use dataverse test;
-
-let $c1 := int8("+80")
-let $c2 := int16("160")
-let $c3 := int32("+320")
-let $c4 := int64("-640")
-return {"int8": numeric-unary-minus($c1),"int16": numeric-unary-minus($c2),"int32": numeric-unary-minus($c3),"int64": numeric-unary-minus($c4)}
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.1.ddl.aql
new file mode 100644
index 0000000..57b3b28
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.1.ddl.aql
@@ -0,0 +1,7 @@
+/**
+ * Interval_bin test case: test the interval-bin function
+ * Expected result: success
+ **/
+
+drop dataverse test if exists;
+create dataverse test;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.2.update.aql
new file mode 100644
index 0000000..e2e3afb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.2.update.aql
@@ -0,0 +1,4 @@
+/**
+ * Interval_bin test case: test the interval-bin function
+ * Expected result: success
+ **/
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.3.query.aql
new file mode 100644
index 0000000..adbb2a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin/interval_bin.3.query.aql
@@ -0,0 +1,19 @@
+/**
+ * Interval_bin test case: test the interval-bin function
+ * Expected result: success
+ **/
+
+use dataverse test;
+
+let $c1 := date("2010-10-30")
+let $c2 := datetime("-1987-11-19T23:49:23.938")
+let $c3 := time("12:23:34.930+07:00")
+
+return { "bin1": interval-bin($c1, date("1990-01-01"), year-month-duration("P1Y")),
+ "bin2": interval-bin($c1, date("-1990-01-01"), year-month-duration("P1Y")),
+ "bin3": interval-bin($c2, datetime("1990-01-01T00:00:00.000Z"), year-month-duration("P6M")),
+ "bin4": interval-bin($c2, datetime("-1990-01-01T00:00:00.000Z"), day-time-duration("PT12H")),
+ "bin5": interval-bin($c3, time("12:00:00"), day-time-duration("PT2H")),
+ "bin6": interval-bin(null, date("-0023-01-01"), year-month-duration("P6M")),
+ "bin7": interval-bin($c1, null, year-month-duration("P6M")),
+ "bin8": interval-bin($c1, date("-0023-01-01"), null) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ddl.aql
new file mode 100644
index 0000000..841d8da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.1.ddl.aql
@@ -0,0 +1,16 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+id: int32,
+timestamp: datetime
+}
+
+create dataset tsdata(Schema)
+primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.2.update.aql
new file mode 100644
index 0000000..b1119e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.2.update.aql
@@ -0,0 +1,18 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+use dataverse test;
+
+insert into dataset tsdata({"id": 1, "timestamp": datetime("-1987-11-19T23:49:23.938")})
+insert into dataset tsdata({"id": 2, "timestamp": datetime("-1987-11-20T00:27:13.432")})
+insert into dataset tsdata({"id": 3, "timestamp": datetime("-1987-11-18T18:00:00")})
+insert into dataset tsdata({"id": 4, "timestamp": datetime("19871119T234923938")})
+insert into dataset tsdata({"id": 5, "timestamp": datetime("1987-11-19T23:58:17.038")})
+insert into dataset tsdata({"id": 6, "timestamp": datetime("1987-11-19T23:30:00")})
+insert into dataset tsdata({"id": 7, "timestamp": datetime("1987-11-19T23:22:38")})
+insert into dataset tsdata({"id": 8, "timestamp": datetime("1988-01-21T17:28:13.900")})
+insert into dataset tsdata({"id": 9, "timestamp": datetime("-1987-11-19T23:49:23.938")})
+insert into dataset tsdata({"id": 10, "timestamp": datetime("-0987-07-01T09:35:28.039")})
+insert into dataset tsdata({"id": 11, "timestamp": datetime("2012-11-19T23:49:23.938")})
+insert into dataset tsdata({"id": 12, "timestamp": datetime("2013-11-19T23:49:23.938")})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.3.query.aql
new file mode 100644
index 0000000..776493f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_0/interval_bin_gby_0.3.query.aql
@@ -0,0 +1,11 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use dataverse test;
+
+for $i in dataset tsdata
+group by $d := interval-bin($i.timestamp, datetime("1990-01-01T00:00:00.000Z"), year-month-duration("P20Y")) with $i
+order by get-interval-start($d)
+return { "tbin": $d, "count": count($i)}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ddl.aql
new file mode 100644
index 0000000..841d8da
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.1.ddl.aql
@@ -0,0 +1,16 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+id: int32,
+timestamp: datetime
+}
+
+create dataset tsdata(Schema)
+primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.2.update.aql
new file mode 100644
index 0000000..b1119e5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.2.update.aql
@@ -0,0 +1,18 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+use dataverse test;
+
+insert into dataset tsdata({"id": 1, "timestamp": datetime("-1987-11-19T23:49:23.938")})
+insert into dataset tsdata({"id": 2, "timestamp": datetime("-1987-11-20T00:27:13.432")})
+insert into dataset tsdata({"id": 3, "timestamp": datetime("-1987-11-18T18:00:00")})
+insert into dataset tsdata({"id": 4, "timestamp": datetime("19871119T234923938")})
+insert into dataset tsdata({"id": 5, "timestamp": datetime("1987-11-19T23:58:17.038")})
+insert into dataset tsdata({"id": 6, "timestamp": datetime("1987-11-19T23:30:00")})
+insert into dataset tsdata({"id": 7, "timestamp": datetime("1987-11-19T23:22:38")})
+insert into dataset tsdata({"id": 8, "timestamp": datetime("1988-01-21T17:28:13.900")})
+insert into dataset tsdata({"id": 9, "timestamp": datetime("-1987-11-19T23:49:23.938")})
+insert into dataset tsdata({"id": 10, "timestamp": datetime("-0987-07-01T09:35:28.039")})
+insert into dataset tsdata({"id": 11, "timestamp": datetime("2012-11-19T23:49:23.938")})
+insert into dataset tsdata({"id": 12, "timestamp": datetime("2013-11-19T23:49:23.938")})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.3.query.aql
new file mode 100644
index 0000000..61a4c5b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_bin_gby_1/interval_bin_gby_1.3.query.aql
@@ -0,0 +1,11 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use dataverse test;
+
+for $i in dataset tsdata
+group by $d := interval-bin(get-time-from-datetime($i.timestamp), time("00:00:00.000Z"), day-time-duration("PT10M")) with $i
+order by get-interval-start($d)
+return { "tbin": $d, "count": count($i)}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_double_01/unary-minus_double_01.1.adm b/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_double_01/unary-minus_double_01.1.adm
deleted file mode 100644
index 3a72bb8..0000000
--- a/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_double_01/unary-minus_double_01.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "double1": 2.056E-29d, "double2": NaNd, "double3": -Infinityd, "double4": Infinityd }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_float_01/unary-minus_float_01.1.adm b/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_float_01/unary-minus_float_01.1.adm
deleted file mode 100644
index e6541ae..0000000
--- a/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_float_01/unary-minus_float_01.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "float1": 80.2f, "float2": NaNf, "float3": -Infinityf, "float4": Infinityf }
diff --git a/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_int_01/unary-minus_int_01.1.adm b/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_int_01/unary-minus_int_01.1.adm
deleted file mode 100644
index 4ecc59b..0000000
--- a/asterix-app/src/test/resources/runtimets/results/numeric/unary-minus_int_01/unary-minus_int_01.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "int8": -80i8, "int16": -160i16, "int32": -320, "int64": 640i64 }
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin/interval_bin.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin/interval_bin.1.adm
new file mode 100644
index 0000000..3ba93a5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin/interval_bin.1.adm
@@ -0,0 +1 @@
+{ "bin1": interval-date("2010-01-01, 2011-01-01"), "bin2": interval-date("2010-01-01, 2011-01-01"), "bin3": interval-datetime("-1987-07-01T00:00:00.000Z, -1986-01-01T00:00:00.000Z"), "bin4": interval-datetime("-1987-11-19T12:00:00.000Z, -1987-11-20T00:00:00.000Z"), "bin5": interval-time("04:00:00.000Z, 06:00:00.000Z"), "bin6": null, "bin7": null, "bin8": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin_gby_0/interval_bin_gby_0.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin_gby_0/interval_bin_gby_0.1.adm
new file mode 100644
index 0000000..c21626b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin_gby_0/interval_bin_gby_0.1.adm
@@ -0,0 +1,4 @@
+{ "tbin": interval-datetime("-1990-01-01T00:00:00.000Z, -1970-01-01T00:00:00.000Z"), "count": 4i64 }
+{ "tbin": interval-datetime("-0990-01-01T00:00:00.000Z, -0970-01-01T00:00:00.000Z"), "count": 1i64 }
+{ "tbin": interval-datetime("1970-01-01T00:00:00.000Z, 1990-01-01T00:00:00.000Z"), "count": 5i64 }
+{ "tbin": interval-datetime("2010-01-01T00:00:00.000Z, 2030-01-01T00:00:00.000Z"), "count": 2i64 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin_gby_1/interval_bin_gby_1.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin_gby_1/interval_bin_gby_1.1.adm
new file mode 100644
index 0000000..b67989d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/interval_bin_gby_1/interval_bin_gby_1.1.adm
@@ -0,0 +1,8 @@
+{ "tbin": interval-time("00:20:00.000Z, 00:30:00.000Z"), "count": 1i64 }
+{ "tbin": interval-time("09:30:00.000Z, 09:40:00.000Z"), "count": 1i64 }
+{ "tbin": interval-time("17:20:00.000Z, 17:30:00.000Z"), "count": 1i64 }
+{ "tbin": interval-time("18:00:00.000Z, 18:10:00.000Z"), "count": 1i64 }
+{ "tbin": interval-time("23:20:00.000Z, 23:30:00.000Z"), "count": 1i64 }
+{ "tbin": interval-time("23:30:00.000Z, 23:40:00.000Z"), "count": 1i64 }
+{ "tbin": interval-time("23:40:00.000Z, 23:50:00.000Z"), "count": 5i64 }
+{ "tbin": interval-time("23:50:00.000Z, 00:00:00.000Z"), "count": 1i64 }
\ 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 65ef11f..95c002e 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4322,6 +4322,21 @@
</test-case>
</test-group>
<test-group name="temporal">
+ <test-case FilePath="temporal">
+ <compilation-unit name="interval_bin">
+ <output-dir compare="Text">interval_bin</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="interval_bin_gby_0">
+ <output-dir compare="Text">interval_bin_gby_0</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="interval_bin_gby_1">
+ <output-dir compare="Text">interval_bin_gby_1</output-dir>
+ </compilation-unit>
+ </test-case>
<test-case FilePath="temporal">
<compilation-unit name="accessors">
<output-dir compare="Text">accessors</output-dir>