ASTERIXDB-1145: verify the Hyracks fix doesn't break a duplicate key insert test case.

Change-Id: I8f770320423d76ba0429213b3376033c4b141fe2
Reviewed-on: https://asterix-gerrit.ics.uci.edu/492
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.1.ddl.aql
new file mode 100644
index 0000000..4c80207
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.1.ddl.aql
@@ -0,0 +1,53 @@
+/*
+ * 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 recovery if exists;
+create dataverse recovery;
+use dataverse recovery;
+
+/* For raw Fragile data */
+create type FragileTypeRaw as closed {
+  row_id: int32,
+  sid: int32,
+  date: string,
+  day: int32,
+  time: string,
+  bpm: int32,
+  RR: float
+};
+
+/* For cleaned Fragile data */
+create type FragileType as closed {
+  row_id: int32,
+  sid: int32,
+  date: date,
+  day: int32,
+  time: time,
+  bpm: int32,
+  RR: float
+};
+
+/* Create dataset for loading raw Fragile data */
+create dataset Fragile_raw (FragileTypeRaw)
+primary key row_id;
+
+/* Create dataset for cleaned Fragile data */
+create dataset Fragile (FragileType)
+primary key row_id;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.2.update.aql
new file mode 100644
index 0000000..dd8d844
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.2.update.aql
@@ -0,0 +1,39 @@
+/*
+ * 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 recovery;
+
+load dataset Fragile_raw using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/csv/fragile_01.csv"),("format"="delimited-text"),("delimiter"=",")) pre-sorted;
+
+use dataverse recovery;
+
+/* Load Fragile data from raw dataset into cleaned dataset */
+insert into dataset Fragile (
+  for $t in dataset Fragile_raw
+  return {
+    "row_id": $t.row_id % 28000,
+    "sid": $t.sid,
+    "date": date($t.date),
+    "day": $t.day,
+    "time": parse-time($t.time, "h:m:s"),
+    "bpm": $t.bpm,
+    "RR": $t.RR
+  }
+);
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.3.ddl.aql
new file mode 100644
index 0000000..ba86f1e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.3.ddl.aql
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+drop dataverse recovery;
+
diff --git a/asterix-app/src/test/resources/runtimets/results/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.1.adm b/asterix-app/src/test/resources/runtimets/results/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/dml/insert-duplicated-keys-from-query/insert-duplicated-keys-from-query.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 4d35ac0..b2ded7b 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -1351,6 +1351,13 @@
         -->
     </test-group>
     <test-group name="dml">
+         <test-case FilePath="dml">
+            <compilation-unit name="insert-duplicated-keys-from-query">
+                <output-dir compare="Text">insert-duplicated-keys-from-query</output-dir>
+                <expected-error>org.apache.hyracks.storage.am.common.exceptions.TreeIndexDuplicateKeyException
+                </expected-error>
+            </compilation-unit>
+        </test-case>
         <test-case FilePath="dml">
             <compilation-unit name="compact-dataset-and-its-indexes">
                 <output-dir compare="Text">compact-dataset-and-its-indexes</output-dir>