ASTERIXDB-1190, ASTERIXDB-1216, ASTERIXDB-1317: fixes and regression tests.
Change-Id: If21ad96b1bff59fa2da601b920d4a61900cad81f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/885
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/query-ASTERIXDB-1216/query-ASTERIXDB-1216.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/query-ASTERIXDB-1216/query-ASTERIXDB-1216.1.query.aql
new file mode 100644
index 0000000..2e277e6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/aggregate/query-ASTERIXDB-1216/query-ASTERIXDB-1216.1.query.aql
@@ -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.
+ */
+
+let $l := [[1.2, 2.3, 3.4],[6,3,7,2]]
+for $x in $l // for each list in the outer list
+return avg($x)
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.1.ddl.aql
new file mode 100644
index 0000000..0beef5a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.1.ddl.aql
@@ -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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type testStringType as open
+{
+ id: int32
+};
+
+create dataset stringTest(testStringType) primary key id;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.2.update.aql
new file mode 100644
index 0000000..19618f0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.2.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+use dataverse test;
+
+insert into dataset stringTest(
+{
+ "id":0,
+ "b":{
+ "c":{
+ "d": "hi"
+ }
+ }
+}
+);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.3.query.aql
new file mode 100644
index 0000000..b5e110e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.3.query.aql
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use dataverse test;
+
+for $x in dataset stringTest
+return string-length($x.b.c.d);
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.1.ddl.aql
new file mode 100644
index 0000000..5c6ce0e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.1.ddl.aql
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type HRMType_Raw as closed {
+ row_id: int32,
+ sid: int32,
+ date: string,
+ day: int32,
+ time: string,
+ bpm: int32,
+ RR: float
+};
+
+create dataset HRM_Raw(HRMType_Raw) primary key row_id;
+
+
+create type HRMType as open {
+ row_id: int32
+};
+
+create dataset HRM(HRMType) primary key row_id;
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.2.update.aql
new file mode 100644
index 0000000..376048c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.2.update.aql
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use dataverse test;
+
+load dataset HRM_Raw using localfs
+ (("path"="asterix_nc1://data/csv/55.csv"),
+ ("format"="delimited-text"),
+ ("header"="true"));
+
+insert into dataset HRM
+(
+ for $t in dataset HRM_Raw
+ return {
+ "row_id": $t.row_id,
+ "sid" : $t.sid,
+ "date" : parse-date($t.date, "YMD"),
+ "time" : parse-time($t.time, "h:m:s"),
+ "day" : $t.day,
+ "bpm" : $t.bpm,
+ "RR" : [$t.RR]
+})
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.3.query.aql
new file mode 100644
index 0000000..6ea0dce
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.3.query.aql
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+use dataverse test;
+
+for $i in dataset HRM
+return
+{
+ "row_id": $i.row_id,
+ "sid": $i.sid,
+ "gdate": $i.date,
+ "gday": $i.day,
+ "timebin": $i.time,
+ "avg_RR_clipped": avg($i.RR)
+};
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
index 49f77e8..78a73736 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
@@ -1 +1 @@
-{ "count1": 4, "count2": 4, "average1": 2.3461845695961844E16d, "sum1": 9.3847382783847376E16d, "min1": 1.0d, "max1": 9.3847382783847376E16d, "average2": 2.3461845695961844E16d, "sum2": 9.3847382783847376E16d, "min2": 1.0d, "max2": 9.3847382783847376E16d }
+{ "count1": 4, "average1": 2.3461845695961844E16d, "count2": 4, "average2": 2.3461845695961844E16d, "sum1": 9.3847382783847376E16d, "min1": 1.0d, "max1": 9.3847382783847376E16d, "sum2": 9.3847382783847376E16d, "min2": 1.0d, "max2": 9.3847382783847376E16d }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/query-ASTERIXDB-1216/query-ASTERIXDB-1216.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/query-ASTERIXDB-1216/query-ASTERIXDB-1216.1.adm
new file mode 100644
index 0000000..dc5444a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate/query-ASTERIXDB-1216/query-ASTERIXDB-1216.1.adm
@@ -0,0 +1,2 @@
+2.3000000000000003d
+4.5d
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_06/customer_q_06.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_06/customer_q_06.1.adm
index 592fed0..b3a7d8d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_06/customer_q_06.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_06/customer_q_06.1.adm
@@ -1,5 +1,5 @@
-{ "customerid": "Jodi Rotruck", "orderedlist": [ 775, 66 ] }
-{ "customerid": "Jodi Alex", "orderedlist": [ 5, 48 ] }
-{ "customerid": "Mike Carey", "orderedlist": [ 1, 18 ] }
-{ "customerid": "Mike ley", "orderedlist": [ 0, 258 ] }
-{ "customerid": "Mary Carey", "orderedlist": [ 4, 4545 ] }
+{ "customerid": "Jodi Rotruck", "orderedlist": [ 775, 66, null ] }
+{ "customerid": "Jodi Alex", "orderedlist": [ 5, 48, null ] }
+{ "customerid": "Mike Carey", "orderedlist": [ 1, 18, null ] }
+{ "customerid": "Mike ley", "orderedlist": [ 0, 258, null ] }
+{ "customerid": "Mary Carey", "orderedlist": [ 4, 4545, null ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_07/customer_q_07.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_07/customer_q_07.1.adm
index db9d858..515e578 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_07/customer_q_07.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/customer_q_07/customer_q_07.1.adm
@@ -1,5 +1,5 @@
-{ "customerid": "Jodi Rotruck", "unorderedlist": {{ 775, 66 }} }
-{ "customerid": "Jodi Alex", "unorderedlist": {{ 5, 48 }} }
-{ "customerid": "Mike Carey", "unorderedlist": {{ 1, 18 }} }
-{ "customerid": "Mike ley", "unorderedlist": {{ 0, 258 }} }
-{ "customerid": "Mary Carey", "unorderedlist": {{ 4, 4545 }} }
+{ "customerid": "Jodi Rotruck", "unorderedlist": {{ 775, 66, null }} }
+{ "customerid": "Jodi Alex", "unorderedlist": {{ 5, 48, null }} }
+{ "customerid": "Mike Carey", "unorderedlist": {{ 1, 18, null }} }
+{ "customerid": "Mike ley", "unorderedlist": {{ 0, 258, null }} }
+{ "customerid": "Mary Carey", "unorderedlist": {{ 4, 4545, null }} }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.1.adm
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/query-ASTERIXDB-1190/query-ASTERIXDB-1190.1.adm
@@ -0,0 +1 @@
+2
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.1.adm
new file mode 100644
index 0000000..4cae610
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/user-defined-functions/query-ASTERIXDB-1317/query-ASTERIXDB-1317.1.adm
@@ -0,0 +1,54 @@
+{ "row_id": 12i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:07.000Z") }
+{ "row_id": 14i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:08.000Z") }
+{ "row_id": 21i32, "avg_RR_clipped": 0.6896551847457886d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:13.000Z") }
+{ "row_id": 23i32, "avg_RR_clipped": 0.6896551847457886d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:14.000Z") }
+{ "row_id": 26i32, "avg_RR_clipped": 0.6185566782951355d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:16.000Z") }
+{ "row_id": 30i32, "avg_RR_clipped": 0.6060606241226196d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:19.000Z") }
+{ "row_id": 33i32, "avg_RR_clipped": 0.5454545617103577d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:21.000Z") }
+{ "row_id": 38i32, "avg_RR_clipped": 0.47999998927116394d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:23.000Z") }
+{ "row_id": 45i32, "avg_RR_clipped": 0.508474588394165d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:27.000Z") }
+{ "row_id": 47i32, "avg_RR_clipped": 0.517241358757019d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:28.000Z") }
+{ "row_id": 49i32, "avg_RR_clipped": 0.5309734344482422d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:29.000Z") }
+{ "row_id": 51i32, "avg_RR_clipped": 0.5357142686843872d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:30.000Z") }
+{ "row_id": 58i32, "avg_RR_clipped": 0.5714285969734192d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:33.000Z") }
+{ "row_id": 60i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:35.000Z") }
+{ "row_id": 13i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:08.000Z") }
+{ "row_id": 15i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:09.000Z") }
+{ "row_id": 16i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:10.000Z") }
+{ "row_id": 19i32, "avg_RR_clipped": 0.6741573214530945d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:12.000Z") }
+{ "row_id": 20i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:12.000Z") }
+{ "row_id": 22i32, "avg_RR_clipped": 0.6976743936538696d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:14.000Z") }
+{ "row_id": 24i32, "avg_RR_clipped": 0.6521739363670349d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:15.000Z") }
+{ "row_id": 29i32, "avg_RR_clipped": 0.6185566782951355d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:18.000Z") }
+{ "row_id": 31i32, "avg_RR_clipped": 0.594059407711029d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:19.000Z") }
+{ "row_id": 35i32, "avg_RR_clipped": 0.5454545617103577d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:22.000Z") }
+{ "row_id": 46i32, "avg_RR_clipped": 0.5128205418586731d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:27.000Z") }
+{ "row_id": 48i32, "avg_RR_clipped": 0.52173912525177d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:28.000Z") }
+{ "row_id": 52i32, "avg_RR_clipped": 0.5405405163764954d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:30.000Z") }
+{ "row_id": 55i32, "avg_RR_clipped": 0.5263158082962036d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:32.000Z") }
+{ "row_id": 56i32, "avg_RR_clipped": 0.5309734344482422d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:32.000Z") }
+{ "row_id": 57i32, "avg_RR_clipped": 0.5357142686843872d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:33.000Z") }
+{ "row_id": 59i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:34.000Z") }
+{ "row_id": 62i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:36.000Z") }
+{ "row_id": 63i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:36.000Z") }
+{ "row_id": 64i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:37.000Z") }
+{ "row_id": 65i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:38.000Z") }
+{ "row_id": 25i32, "avg_RR_clipped": 0.6382978558540344d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:16.000Z") }
+{ "row_id": 28i32, "avg_RR_clipped": 0.6315789222717285d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:17.000Z") }
+{ "row_id": 34i32, "avg_RR_clipped": 0.5769230723381042d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:21.000Z") }
+{ "row_id": 37i32, "avg_RR_clipped": 0.4958677589893341d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:23.000Z") }
+{ "row_id": 40i32, "avg_RR_clipped": 0.4878048896789551d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:24.000Z") }
+{ "row_id": 41i32, "avg_RR_clipped": 0.49180328845977783d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:25.000Z") }
+{ "row_id": 43i32, "avg_RR_clipped": 0.5d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:26.000Z") }
+{ "row_id": 17i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:10.000Z") }
+{ "row_id": 18i32, "avg_RR_clipped": 0.6666666865348816d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:11.000Z") }
+{ "row_id": 27i32, "avg_RR_clipped": 0.6185566782951355d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:17.000Z") }
+{ "row_id": 32i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:20.000Z") }
+{ "row_id": 36i32, "avg_RR_clipped": 0.5128205418586731d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:22.000Z") }
+{ "row_id": 39i32, "avg_RR_clipped": 0.4838709533214569d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:24.000Z") }
+{ "row_id": 42i32, "avg_RR_clipped": 0.4958677589893341d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:25.000Z") }
+{ "row_id": 44i32, "avg_RR_clipped": 0.5042017102241516d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:26.000Z") }
+{ "row_id": 50i32, "avg_RR_clipped": 0.5309734344482422d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:29.000Z") }
+{ "row_id": 53i32, "avg_RR_clipped": 0.5128205418586731d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:31.000Z") }
+{ "row_id": 54i32, "avg_RR_clipped": 0.52173912525177d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:31.000Z") }
+{ "row_id": 61i32, "avg_RR_clipped": 0.582524299621582d, "sid": 55i32, "gdate": date("2014-01-08"), "gday": 1i32, "timebin": time("11:45:35.000Z") }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index 27aa7be..0b19e22 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -530,6 +530,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="aggregate">
+ <compilation-unit name="query-ASTERIXDB-1216">
+ <output-dir compare="Text">query-ASTERIXDB-1216</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
<compilation-unit name="group_only">
<output-dir compare="Text">group_only</output-dir>
</compilation-unit>
@@ -5457,6 +5462,11 @@
<output-dir compare="Text">varlen-encoding</output-dir>
</compilation-unit>
</test-case>
+ <test-case FilePath="string">
+ <compilation-unit name="query-ASTERIXDB-1190">
+ <output-dir compare="Text">query-ASTERIXDB-1190</output-dir>
+ </compilation-unit>
+ </test-case>
</test-group>
<test-group name="subset-collection">
<test-case FilePath="subset-collection">
@@ -6243,6 +6253,11 @@
<output-dir compare="Text">query-ASTERIXDB-1308-1</output-dir>
</compilation-unit>
</test-case>
+ <test-case FilePath="user-defined-functions">
+ <compilation-unit name="query-ASTERIXDB-1317">
+ <output-dir compare="Text">query-ASTERIXDB-1317</output-dir>
+ </compilation-unit>
+ </test-case>
<!-- <test-case FilePath="user-defined-functions">
<compilation-unit name="query-ASTERIXDB-1308-2">
<output-dir compare="Text">query-ASTERIXDB-1308-2</output-dir>
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
index 4cd3015..c5ceb1a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
@@ -23,7 +23,6 @@
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.AsterixExternalFunctionInfo;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -34,8 +33,6 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
@@ -50,30 +47,22 @@
public Object getType(ILogicalExpression expr, IMetadataProvider<?, ?> metadataProvider,
IVariableTypeEnvironment env) throws AlgebricksException {
switch (expr.getExpressionTag()) {
- case CONSTANT: {
+ case CONSTANT:
return getTypeForConstant((ConstantExpression) expr, env);
- }
- case FUNCTION_CALL: {
+ case FUNCTION_CALL:
return getTypeForFunction((AbstractFunctionCallExpression) expr, env, metadataProvider);
- }
- case VARIABLE: {
+ case VARIABLE:
return env.getVarType(((VariableReferenceExpression) expr).getVariableReference());
- }
- default: {
+ default:
throw new IllegalStateException();
- }
}
}
private IAType getTypeForFunction(AbstractFunctionCallExpression expr, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> mp) throws AlgebricksException {
FunctionIdentifier fi = expr.getFunctionIdentifier();
- ComparisonKind ck = AlgebricksBuiltinFunctions.getComparisonType(fi);
- if (ck != null) {
- return AUnionType.createUnknownableType(BuiltinType.ABOOLEAN, "OptionalBoolean");
- }
// Note: built-in functions + udfs
- IResultTypeComputer rtc = null;
+ IResultTypeComputer rtc;
FunctionSignature signature = new FunctionSignature(fi.getNamespace(), fi.getName(), fi.getArity());
if (AsterixBuiltinFunctions.isBuiltinCompilerFunction(signature, true)) {
rtc = AsterixBuiltinFunctions.getResultTypeComputer(fi);
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 0bf2841..fafbb4d 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
@@ -77,7 +77,7 @@
import org.apache.asterix.om.typecomputer.impl.NumericUnaryFunctionTypeComputer;
import org.apache.asterix.om.typecomputer.impl.OpenARecordTypeComputer;
import org.apache.asterix.om.typecomputer.impl.OpenRecordConstructorResultType;
-import org.apache.asterix.om.typecomputer.impl.OrderedListConstructorResultType;
+import org.apache.asterix.om.typecomputer.impl.OrderedListConstructorTypeComputer;
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAInt32TypeComputer;
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAInt64TypeComputer;
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAIntervalTypeComputer;
@@ -97,7 +97,7 @@
import org.apache.asterix.om.typecomputer.impl.UnaryBinaryInt64TypeComputer;
import org.apache.asterix.om.typecomputer.impl.UnaryMinusTypeComputer;
import org.apache.asterix.om.typecomputer.impl.UnaryStringInt64TypeComputer;
-import org.apache.asterix.om.typecomputer.impl.UnorderedListConstructorResultType;
+import org.apache.asterix.om.typecomputer.impl.UnorderedListConstructorTypeComputer;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -792,7 +792,7 @@
addFunction(INT64_CONSTRUCTOR, AInt64TypeComputer.INSTANCE, true);
addFunction(LEN, AInt64TypeComputer.INSTANCE, true);
addFunction(LINE_CONSTRUCTOR, ALineTypeComputer.INSTANCE, true);
- addPrivateFunction(LISTIFY, OrderedListConstructorResultType.INSTANCE, true);
+ addPrivateFunction(LISTIFY, OrderedListConstructorTypeComputer.INSTANCE, true);
addPrivateFunction(MAKE_FIELD_INDEX_HANDLE, null, true); // TODO
addPrivateFunction(MAKE_FIELD_NAME_HANDLE, null, true); // TODO
addFunction(NULL_CONSTRUCTOR, AMissingTypeComputer.INSTANCE, true);
@@ -839,7 +839,7 @@
addPrivateFunction(STRING_EQUAL, StringBooleanTypeComputer.INSTANCE, true);
addFunction(STRING_JOIN, AStringTypeComputer.INSTANCE, true);
- addPrivateFunction(ORDERED_LIST_CONSTRUCTOR, OrderedListConstructorResultType.INSTANCE, true);
+ addPrivateFunction(ORDERED_LIST_CONSTRUCTOR, OrderedListConstructorTypeComputer.INSTANCE, true);
addFunction(POINT_CONSTRUCTOR, APointTypeComputer.INSTANCE, true);
addFunction(POINT3D_CONSTRUCTOR, APoint3DTypeComputer.INSTANCE, true);
addFunction(POLYGON_CONSTRUCTOR, APolygonTypeComputer.INSTANCE, true);
@@ -867,10 +867,10 @@
addPrivateFunction(SERIAL_INTERMEDIATE_SQL_AVG, LocalAvgTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_SQL_SUM, NumericAggTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_LOCAL_SQL_SUM, NumericAggTypeComputer.INSTANCE, true);
- addFunction(SCALAR_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addFunction(SCALAR_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addFunction(SCALAR_COUNT, AInt64TypeComputer.INSTANCE, true);
- addPrivateFunction(SCALAR_GLOBAL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addPrivateFunction(SCALAR_LOCAL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addPrivateFunction(SCALAR_GLOBAL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_LOCAL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addFunction(SCALAR_MAX, ScalarVersionOfAggregateResultType.INSTANCE, true);
addFunction(SCALAR_MIN, ScalarVersionOfAggregateResultType.INSTANCE, true);
addFunction(SCALAR_SUM, ScalarVersionOfAggregateResultType.INSTANCE, true);
@@ -889,16 +889,16 @@
addPrivateFunction(LOCAL_SQL_SUM, NumericAggTypeComputer.INSTANCE, true);
addFunction(SCALAR_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addFunction(SCALAR_SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
- addPrivateFunction(SCALAR_GLOBAL_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addPrivateFunction(SCALAR_LOCAL_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addPrivateFunction(SCALAR_GLOBAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_LOCAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addFunction(SCALAR_SQL_MAX, ScalarVersionOfAggregateResultType.INSTANCE, true);
addFunction(SCALAR_SQL_MIN, ScalarVersionOfAggregateResultType.INSTANCE, true);
addFunction(SCALAR_SQL_SUM, ScalarVersionOfAggregateResultType.INSTANCE, true);
addPrivateFunction(INTERMEDIATE_SQL_AVG, LocalAvgTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_AVG, ADoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_COUNT, AInt64TypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_GLOBAL_AVG, ADoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_GLOBAL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_LOCAL_AVG, LocalAvgTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_INTERMEDIATE_AVG, LocalAvgTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_SUM, NumericAggTypeComputer.INSTANCE, true);
@@ -940,7 +940,7 @@
addFunction(TID, AInt64TypeComputer.INSTANCE, true);
addFunction(TIME_CONSTRUCTOR, ATimeTypeComputer.INSTANCE, true);
addPrivateFunction(TYPE_OF, null, true);
- addPrivateFunction(UNORDERED_LIST_CONSTRUCTOR, UnorderedListConstructorResultType.INSTANCE, true);
+ addPrivateFunction(UNORDERED_LIST_CONSTRUCTOR, UnorderedListConstructorTypeComputer.INSTANCE, true);
addFunction(WORD_TOKENS, OrderedListOfAStringTypeComputer.INSTANCE, true);
// records
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
index fa944c6..95d8508 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
@@ -19,6 +19,7 @@
package org.apache.asterix.om.typecomputer.impl;
import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -38,11 +39,11 @@
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
// Boolean type computer doesn't follow the null/missing-in/out semantics.
return TypeComputeUtils.resolveResultType(expression, env, (index, type) -> checkArgType(index, type),
- types -> getResultType(types), false);
+ this::getResultType, false);
}
@Override
protected IAType getResultType(IAType... strippedInputTypes) {
- return BuiltinType.ABOOLEAN;
+ return AUnionType.createUnknownableType(BuiltinType.ABOOLEAN);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ListConstructorTypeComputer.java
similarity index 73%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorResultType.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ListConstructorTypeComputer.java
index 1e1d753..2528697 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ListConstructorTypeComputer.java
@@ -22,8 +22,6 @@
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.AUnorderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -32,40 +30,45 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class UnorderedListConstructorResultType implements IResultTypeComputer {
+public abstract class ListConstructorTypeComputer implements IResultTypeComputer {
- public static final UnorderedListConstructorResultType INSTANCE = new UnorderedListConstructorResultType();
+ protected ListConstructorTypeComputer() {
+ }
@Override
- public AUnorderedListType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+ public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
/**
* if type has been top-down propagated, use the enforced type
*/
- AUnorderedListType reqType = (AUnorderedListType) TypeCastUtils.getRequiredType(f);
+ IAType reqType = TypeCastUtils.getRequiredType(f);
if (reqType != null) {
return reqType;
}
+ return computeTypeFromItems(env, f);
+ }
+ private IAType computeTypeFromItems(IVariableTypeEnvironment env, AbstractFunctionCallExpression f)
+ throws AlgebricksException {
IAType currentType = null;
boolean any = false;
for (int k = 0; k < f.getArguments().size(); k++) {
IAType type = (IAType) env.getType(f.getArguments().get(k).getValue());
- if (type.getTypeTag() == ATypeTag.UNION) {
- type = ((AUnionType) type).getActualType();
- }
- if (currentType != null && !currentType.equals(type)) {
+ if (type.getTypeTag() == ATypeTag.UNION || (currentType != null && !currentType.equals(type))) {
any = true;
break;
}
currentType = type;
}
if (any || currentType == null) {
- return new AUnorderedListType(BuiltinType.ANY, null);
+ return getListType(BuiltinType.ANY);
} else {
- return new AUnorderedListType(currentType, null);
+ return getListType(currentType);
}
}
+
+ protected abstract IAType getListType(IAType itemType);
+
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
deleted file mode 100644
index 70a0ca5..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
-import org.apache.asterix.om.types.AOrderedListType;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OrderedListConstructorResultType implements IResultTypeComputer {
-
- public static final OrderedListConstructorResultType INSTANCE = new OrderedListConstructorResultType();
-
- @Override
- public AOrderedListType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-
- /**
- * if type has been top-down propagated, use the enforced type
- */
- AOrderedListType reqType = (AOrderedListType) TypeCastUtils.getRequiredType(f);
- if (reqType != null) {
- return reqType;
- }
-
- IAType currentType = null;
- boolean any = false;
- for (int k = 0; k < f.getArguments().size(); k++) {
- IAType type = (IAType) env.getType(f.getArguments().get(k).getValue());
- if (type.getTypeTag() == ATypeTag.UNION) {
- type = ((AUnionType) type).getActualType();
- }
- if (currentType != null && !currentType.equals(type)) {
- any = true;
- break;
- }
- currentType = type;
- }
- if (any || currentType == null) {
- return new AOrderedListType(BuiltinType.ANY, null);
- } else {
- return new AOrderedListType(currentType, null);
- }
-
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorTypeComputer.java
new file mode 100644
index 0000000..a384923
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorTypeComputer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.om.typecomputer.impl;
+
+import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.IAType;
+
+public class OrderedListConstructorTypeComputer extends ListConstructorTypeComputer {
+ public static final OrderedListConstructorTypeComputer INSTANCE = new OrderedListConstructorTypeComputer();
+
+ private OrderedListConstructorTypeComputer() {
+ }
+
+ @Override
+ protected IAType getListType(IAType itemType) {
+ return new AOrderedListType(itemType, null);
+ }
+
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorTypeComputer.java
new file mode 100644
index 0000000..2d67aad
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorTypeComputer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.om.typecomputer.impl;
+
+import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.asterix.om.types.IAType;
+
+public class UnorderedListConstructorTypeComputer extends ListConstructorTypeComputer {
+ public static final UnorderedListConstructorTypeComputer INSTANCE = new UnorderedListConstructorTypeComputer();
+
+ private UnorderedListConstructorTypeComputer() {
+ }
+
+ @Override
+ protected IAType getListType(IAType itemType) {
+ return new AUnorderedListType(itemType, null);
+ }
+
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
index 5811cd6..64735ff 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -61,7 +61,6 @@
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.AUnorderedListType;
import org.apache.asterix.om.types.AbstractCollectionType;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.aggregates.collections.ListifyAggregateDescriptor;
import org.apache.asterix.runtime.evaluators.common.CreateMBREvalFactory;
@@ -376,21 +375,7 @@
@Override
public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
throws AlgebricksException {
- AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
- if (f.getArguments().size() == 0) {
- ((ListifyAggregateDescriptor) fd).reset(new AOrderedListType(null, null));
- } else {
- IAType itemType = (IAType) context.getType(f.getArguments().get(0).getValue());
- if (itemType instanceof AUnionType) {
- if (((AUnionType) itemType).isUnknownableType()) {
- itemType = ((AUnionType) itemType).getActualType();
- } else {
- // Convert UNION types into ANY.
- itemType = BuiltinType.ANY;
- }
- }
- ((ListifyAggregateDescriptor) fd).reset(new AOrderedListType(itemType, null));
- }
+ ((ListifyAggregateDescriptor) fd).reset((AOrderedListType) context.getType(expr));
}
});
functionTypeInferers.put(AsterixBuiltinFunctions.RECORD_MERGE, new FunctionTypeInferer() {