You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by ht...@apache.org on 2019/05/15 10:31:05 UTC

[asterixdb] branch master updated: [ASTERIXDB-2535][COMP] Fix uuid present in insert/upsert statement

This is an automated email from the ASF dual-hosted git repository.

htowaileb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new cd01c55  [ASTERIXDB-2535][COMP] Fix uuid present in insert/upsert statement
cd01c55 is described below

commit cd01c55b14ead23be7e9f557f285b4a69d5e8008
Author: Hussain Towaileb <Hu...@Gmail.com>
AuthorDate: Tue May 14 23:28:55 2019 +0300

    [ASTERIXDB-2535][COMP] Fix uuid present in insert/upsert statement
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Added a new record merge function, extending the old one, to handle
    the merge of duplicate fields.
    - Updated the record merge type computer to handle the merge of
    duplicate fields properly at compile time.
    - Added a new record merge descriptor and evaluator, extending
    the old one, to handle the merge of duplicate fields properly
    at runtime.
    - Updated IntroduceAutogenerateIDRule to use the new record merge
    function.
    - Added test cases to test the newly added function for insert
    and upsert statements.
    
    Change-Id: I22100d3ff29864b8bfd54b0decb183e5056fdb4a
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3370
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Hussain Towaileb <hu...@gmail.com>
---
 .../rules/IntroduceAutogenerateIDRule.java         |   2 +-
 .../insert_nested_uuid_autogenerate.1.ddl.sqlpp    |  33 +++
 .../insert_nested_uuid_autogenerate.2.update.sqlpp |  24 +++
 .../insert_nested_uuid_autogenerate.3.query.sqlpp  |  23 ++
 .../insert_nested_uuid_manual.1.ddl.sqlpp          |  33 +++
 .../insert_nested_uuid_manual.2.update.sqlpp       |  24 +++
 .../insert_nested_uuid_manual.3.query.sqlpp        |  23 ++
 .../insert_nested_uuid_manual_exists.1.ddl.sqlpp   |  33 +++
 ...insert_nested_uuid_manual_exists.2.update.sqlpp |  31 +++
 ...rt_nested_uuid_manual_exists_select.1.ddl.sqlpp |  33 +++
 ...nested_uuid_manual_exists_select.2.update.sqlpp |  33 +++
 .../insert_uuid_autogenerate.1.ddl.sqlpp           |  29 +++
 .../insert_uuid_autogenerate.2.update.sqlpp        |  24 +++
 .../insert_uuid_autogenerate.3.query.sqlpp         |  23 ++
 .../insert_uuid_manual.1.ddl.sqlpp                 |  29 +++
 .../insert_uuid_manual.2.update.sqlpp              |  24 +++
 .../insert_uuid_manual.3.query.sqlpp               |  23 ++
 .../insert_uuid_manual_exists.1.ddl.sqlpp          |  29 +++
 .../insert_uuid_manual_exists.2.update.sqlpp       |  31 +++
 .../insert_uuid_manual_exists_select.1.ddl.sqlpp   |  29 +++
 ...insert_uuid_manual_exists_select.2.update.sqlpp |  33 +++
 .../upsert_nested_uuid_autogenerate.1.ddl.sqlpp    |  33 +++
 .../upsert_nested_uuid_autogenerate.2.update.sqlpp |  24 +++
 .../upsert_nested_uuid_autogenerate.3.query.sqlpp  |  23 ++
 .../upsert_nested_uuid_manual.1.ddl.sqlpp          |  33 +++
 .../upsert_nested_uuid_manual.2.update.sqlpp       |  24 +++
 .../upsert_nested_uuid_manual.3.query.sqlpp        |  23 ++
 .../upsert_nested_uuid_manual_exists.1.ddl.sqlpp   |  33 +++
 ...upsert_nested_uuid_manual_exists.2.update.sqlpp |  31 +++
 .../upsert_nested_uuid_manual_exists.3.query.sqlpp |  23 ++
 ...sert_auto_nested_uuid_exists_select.1.ddl.sqlpp |  33 +++
 ...t_auto_nested_uuid_exists_select.2.update.sqlpp |  33 +++
 ...rt_auto_nested_uuid_exists_select.3.query.sqlpp |  23 ++
 .../upsert_uuid_autogenerate.1.ddl.sqlpp           |  29 +++
 .../upsert_uuid_autogenerate.2.update.sqlpp        |  24 +++
 .../upsert_uuid_autogenerate.3.query.sqlpp         |  23 ++
 .../upsert_uuid_manual.1.ddl.sqlpp                 |  29 +++
 .../upsert_uuid_manual.2.update.sqlpp              |  24 +++
 .../upsert_uuid_manual.3.query.sqlpp               |  23 ++
 .../upsert_uuid_manual_exists.1.ddl.sqlpp          |  29 +++
 .../upsert_uuid_manual_exists.2.update.sqlpp       |  31 +++
 .../upsert_uuid_manual_exists.3.query.sqlpp        |  23 ++
 .../upsert_uuid_manual_exists_select.1.ddl.sqlpp   |  29 +++
 ...upsert_uuid_manual_exists_select.2.update.sqlpp |  33 +++
 .../upsert_uuid_manual_exists_select.3.query.sqlpp |  23 ++
 .../insert_nested_uuid_autogenerate.1.adm          |   1 +
 .../insert_nested_uuid_manual.1.adm                |   1 +
 .../insert_nested_uuid_manual_exists.1.adm         |   0
 .../insert_nested_uuid_manual_exists_select.1.adm  |   0
 .../insert_uuid_autogenerate.1.adm                 |   1 +
 .../insert_uuid_manual/insert_uuid_manual.1.adm    |   1 +
 .../insert_uuid_manual_exists.1.adm                |   0
 .../insert_uuid_manual_exists_select.1.adm         |   0
 .../upsert_nested_uuid_autogenerate.1.adm          |   1 +
 .../upsert_nested_uuid_manual.1.adm                |   1 +
 .../upsert_nested_uuid_manual_exists.1.adm         |   3 +
 .../upsert_nested_uuid_manual_exists_select.1.adm  |   2 +
 .../upsert_uuid_autogenerate.1.adm                 |   1 +
 .../upsert_uuid_manual/upsert_uuid_manual.1.adm    |   1 +
 .../upsert_uuid_manual_exists.1.adm                |   3 +
 .../upsert_uuid_manual_exists_select.1.adm         |   2 +
 .../test/resources/runtimets/testsuite_sqlpp.xml   |  91 +++++++-
 .../asterix/om/functions/BuiltinFunctions.java     |   3 +
 .../typecomputer/impl/RecordMergeTypeComputer.java |  35 ++-
 .../functions/records/RecordMergeDescriptor.java   | 184 +---------------
 .../functions/records/RecordMergeEvaluator.java    | 240 +++++++++++++++++++++
 .../RecordMergeIgnoreDuplicatesDescriptor.java     |  96 +++++++++
 .../runtime/functions/FunctionCollection.java      |   2 +
 68 files changed, 1703 insertions(+), 188 deletions(-)

diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java
index f1b20d8..1fb035f 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java
@@ -233,7 +233,7 @@ public class IntroduceAutogenerateIDRule implements IAlgebraicRewriteRule {
         recordMergeFnArgs.add(new MutableObject<>(rec0));
         recordMergeFnArgs.add(new MutableObject<>(rec1));
         AbstractFunctionCallExpression recordMergeFn = new ScalarFunctionCallExpression(
-                FunctionUtil.getFunctionInfo(BuiltinFunctions.RECORD_MERGE), recordMergeFnArgs);
+                FunctionUtil.getFunctionInfo(BuiltinFunctions.RECORD_MERGE_IGNORE_DUPLICATES), recordMergeFnArgs);
         recordMergeFn.setSourceLocation(sourceLoc);
         return recordMergeFn;
     }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.2.update.sqlpp
new file mode 100644
index 0000000..e556569
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.2.update.sqlpp
@@ -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 test;
+
+insert into test([
+{ "comment": "manual uuid" }
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.3.query.sqlpp
new file mode 100644
index 0000000..3c22235
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select value count(*)
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.2.update.sqlpp
new file mode 100644
index 0000000..44003dd
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.2.update.sqlpp
@@ -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 test;
+
+insert into test([
+{ "nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid" }
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.3.query.sqlpp
new file mode 100644
index 0000000..0fa5531
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select nested, comment
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.2.update.sqlpp
new file mode 100644
index 0000000..f65c1ac
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.2.update.sqlpp
@@ -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 test;
+
+insert into test([
+{"nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid"},
+{"nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid"}
+]);
+
+insert into test([
+{"nested": { "id": uuid("673a5fa3-2ee5-c55e-2cbd-1da05cfddae6") }, "comment": "manual uuid"},
+{"nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid - updated"},
+{"nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid - updated", "extra": "extra"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.2.update.sqlpp
new file mode 100644
index 0000000..4af65f4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.2.update.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+insert into test([
+{"nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid"},
+{"nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid"}
+]);
+
+insert into test(
+select nested, "manual uuid - updated" as comment, "extra" as extra
+from test
+where nested.id IN [
+uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"),
+uuid("5585eec5-133a-72b6-296b-44a5e303050c")
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.2.update.sqlpp
new file mode 100644
index 0000000..4b3d670
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.2.update.sqlpp
@@ -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 test;
+
+insert into test([
+{"comment": "manual uuid"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.3.query.sqlpp
new file mode 100644
index 0000000..3c22235
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select value count(*)
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.2.update.sqlpp
new file mode 100644
index 0000000..04ca86e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.2.update.sqlpp
@@ -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 test;
+
+insert into test([
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.3.query.sqlpp
new file mode 100644
index 0000000..bf7ee3a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual/insert_uuid_manual.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select id, comment
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.2.update.sqlpp
new file mode 100644
index 0000000..ed9d464
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.2.update.sqlpp
@@ -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 test;
+
+insert into test([
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid"},
+{"id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid"}
+]);
+
+insert into test([
+{"id": uuid("673a5fa3-2ee5-c55e-2cbd-1da05cfddae6"), "comment": "manual uuid"},
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid - updated"},
+{"id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid - updated", "extra": "extra"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.2.update.sqlpp
new file mode 100644
index 0000000..a96def2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.2.update.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+insert into test([
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid"},
+{"id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid"}
+]);
+
+insert into test(
+select id, "manual uuid - updated" as comment, "extra" as extra
+from test
+where id IN [
+uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"),
+uuid("5585eec5-133a-72b6-296b-44a5e303050c")
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.2.update.sqlpp
new file mode 100644
index 0000000..2b16879
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.2.update.sqlpp
@@ -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 test;
+
+upsert into test([
+{ "comment": "manual uuid" }
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.3.query.sqlpp
new file mode 100644
index 0000000..3c22235
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select value count(*)
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.2.update.sqlpp
new file mode 100644
index 0000000..b52e2a0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.2.update.sqlpp
@@ -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 test;
+
+upsert into test([
+{ "nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid" }
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.3.query.sqlpp
new file mode 100644
index 0000000..0fa5531
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select nested, comment
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.2.update.sqlpp
new file mode 100644
index 0000000..ca3b434
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.2.update.sqlpp
@@ -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 test;
+
+upsert into test([
+{"nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid", "extra": "extra"},
+{"nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid"}
+]);
+
+upsert into test([
+{"nested": { "id": uuid("673a5fa3-2ee5-c55e-2cbd-1da05cfddae6") }, "comment": "manual uuid"},
+{"nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid - updated"},
+{"nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid - updated", "extra": "extra"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.3.query.sqlpp
new file mode 100644
index 0000000..e1d89bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select nested, comment, extra
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.1.ddl.sqlpp
new file mode 100644
index 0000000..39ea365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+create type nested as {
+id: uuid
+};
+
+create type test as {
+nested: nested,
+comment: string
+};
+
+create dataset test(test) primary key nested.id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.2.update.sqlpp
new file mode 100644
index 0000000..278f648
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.2.update.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+upsert into test([
+{"nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid"},
+{"nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid"}
+]);
+
+upsert into test(
+select nested, "manual uuid - updated" as comment, "extra" as extra
+from test
+where nested.id IN [
+uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"),
+uuid("5585eec5-133a-72b6-296b-44a5e303050c")
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.3.query.sqlpp
new file mode 100644
index 0000000..e1d89bf
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_nested_uuid_manual_exists_select/upsert_auto_nested_uuid_exists_select.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select nested, comment, extra
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.2.update.sqlpp
new file mode 100644
index 0000000..b7c6b07
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.2.update.sqlpp
@@ -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 test;
+
+upsert into test([
+{"comment": "manual uuid"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.3.query.sqlpp
new file mode 100644
index 0000000..3c22235
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select value count(*)
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.2.update.sqlpp
new file mode 100644
index 0000000..dba7ade
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.2.update.sqlpp
@@ -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 test;
+
+upsert into test([
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.3.query.sqlpp
new file mode 100644
index 0000000..bf7ee3a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual/upsert_uuid_manual.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select id, comment
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.2.update.sqlpp
new file mode 100644
index 0000000..265ff24
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.2.update.sqlpp
@@ -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 test;
+
+upsert into test([
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid", "extra": "extra"},
+{"id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid"}
+]);
+
+upsert into test([
+{"id": uuid("673a5fa3-2ee5-c55e-2cbd-1da05cfddae6"), "comment": "manual uuid"},
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid - updated"},
+{"id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid - updated", "extra": "extra"}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.3.query.sqlpp
new file mode 100644
index 0000000..5b20c1e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select id, comment, extra
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.1.ddl.sqlpp
new file mode 100644
index 0000000..06c6f2c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.1.ddl.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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type test as {
+id: uuid,
+comment: string
+};
+
+create dataset test(test) primary key id autogenerated;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.2.update.sqlpp
new file mode 100644
index 0000000..9acb12a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.2.update.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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 test;
+
+upsert into test([
+{"id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid"},
+{"id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid"}
+]);
+
+upsert into test(
+select id, "manual uuid - updated" as comment, "extra" as extra
+from test
+where id IN [
+uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"),
+uuid("5585eec5-133a-72b6-296b-44a5e303050c")
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.3.query.sqlpp
new file mode 100644
index 0000000..5b20c1e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.3.query.sqlpp
@@ -0,0 +1,23 @@
+/*
+ * 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 test;
+
+select id, comment, extra
+from test;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.1.adm
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_autogenerate/insert_nested_uuid_autogenerate.1.adm
@@ -0,0 +1 @@
+1
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.1.adm
new file mode 100644
index 0000000..5372d39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_manual/insert_nested_uuid_manual.1.adm
@@ -0,0 +1 @@
+{ "nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_manual_exists/insert_nested_uuid_manual_exists.1.adm
new file mode 100644
index 0000000..e69de29
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_nested_uuid_manual_exists_select/insert_nested_uuid_manual_exists_select.1.adm
new file mode 100644
index 0000000..e69de29
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.1.adm
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_autogenerate/insert_uuid_autogenerate.1.adm
@@ -0,0 +1 @@
+1
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_manual/insert_uuid_manual.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_manual/insert_uuid_manual.1.adm
new file mode 100644
index 0000000..960a668
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_manual/insert_uuid_manual.1.adm
@@ -0,0 +1 @@
+{ "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_manual_exists/insert_uuid_manual_exists.1.adm
new file mode 100644
index 0000000..e69de29
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/insert_uuid_manual_exists_select/insert_uuid_manual_exists_select.1.adm
new file mode 100644
index 0000000..e69de29
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.1.adm
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_autogenerate/upsert_nested_uuid_autogenerate.1.adm
@@ -0,0 +1 @@
+1
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.1.adm
new file mode 100644
index 0000000..5372d39
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual/upsert_nested_uuid_manual.1.adm
@@ -0,0 +1 @@
+{ "nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.1.adm
new file mode 100644
index 0000000..4bf7665
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual_exists/upsert_nested_uuid_manual_exists.1.adm
@@ -0,0 +1,3 @@
+{ "nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid - updated" }
+{ "nested": { "id": uuid("673a5fa3-2ee5-c55e-2cbd-1da05cfddae6") }, "comment": "manual uuid" }
+{ "nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid - updated", "extra": "extra" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual_exists_select/upsert_nested_uuid_manual_exists_select.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual_exists_select/upsert_nested_uuid_manual_exists_select.1.adm
new file mode 100644
index 0000000..74d1066
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_nested_uuid_manual_exists_select/upsert_nested_uuid_manual_exists_select.1.adm
@@ -0,0 +1,2 @@
+{ "nested": { "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188") }, "comment": "manual uuid - updated", "extra": "extra" }
+{ "nested": { "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c") }, "comment": "manual uuid - updated", "extra": "extra" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.1.adm
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_autogenerate/upsert_uuid_autogenerate.1.adm
@@ -0,0 +1 @@
+1
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual/upsert_uuid_manual.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual/upsert_uuid_manual.1.adm
new file mode 100644
index 0000000..960a668
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual/upsert_uuid_manual.1.adm
@@ -0,0 +1 @@
+{ "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.1.adm
new file mode 100644
index 0000000..df1039a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual_exists/upsert_uuid_manual_exists.1.adm
@@ -0,0 +1,3 @@
+{ "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid - updated" }
+{ "id": uuid("673a5fa3-2ee5-c55e-2cbd-1da05cfddae6"), "comment": "manual uuid" }
+{ "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid - updated", "extra": "extra" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.1.adm
new file mode 100644
index 0000000..aea50ed
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/dml/upsert_uuid_manual_exists_select/upsert_uuid_manual_exists_select.1.adm
@@ -0,0 +1,2 @@
+{ "id": uuid("673a5fa3-60e5-c55e-2ebb-09344f3e1188"), "comment": "manual uuid - updated", "extra": "extra" }
+{ "id": uuid("5585eec5-133a-72b6-296b-44a5e303050c"), "comment": "manual uuid - updated", "extra": "extra" }
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 8e96fc5..ed28b24 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3712,7 +3712,8 @@
     <test-case FilePath="dml">
       <compilation-unit name="insert-with-autogenerated-pk_adm_02">
         <output-dir compare="Text">insert-with-autogenerated-pk_adm_02</output-dir>
-        <expected-error>Duplicate field name &quot;id&quot;</expected-error>
+        <expected-error>Field type string cannot be promoted to type uuid</expected-error>
+        <source-location>false</source-location>
       </compilation-unit>
     </test-case>
     <test-case FilePath="dml">
@@ -3789,6 +3790,94 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="dml">
+      <compilation-unit name="insert_uuid_autogenerate">
+        <output-dir compare="Text">insert_uuid_autogenerate</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_uuid_autogenerate">
+        <output-dir compare="Text">upsert_uuid_autogenerate</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="insert_uuid_manual">
+        <output-dir compare="Text">insert_uuid_manual</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_uuid_manual">
+        <output-dir compare="Text">upsert_uuid_manual</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="insert_uuid_manual_exists">
+        <output-dir compare="Text">insert_uuid_manual_exists</output-dir>
+        <expected-error>Inserting duplicate keys into the primary storage</expected-error>
+        <source-location>false</source-location>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_uuid_manual_exists">
+        <output-dir compare="Text">upsert_uuid_manual_exists</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="insert_uuid_manual_exists_select">
+        <output-dir compare="Text">insert_uuid_manual_exists_select</output-dir>
+        <expected-error>Inserting duplicate keys into the primary storage</expected-error>
+        <source-location>false</source-location>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_uuid_manual_exists_select">
+        <output-dir compare="Text">upsert_uuid_manual_exists_select</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="insert_nested_uuid_autogenerate">
+        <output-dir compare="Text">insert_nested_uuid_autogenerate</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_nested_uuid_autogenerate">
+        <output-dir compare="Text">upsert_nested_uuid_autogenerate</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="insert_nested_uuid_manual">
+        <output-dir compare="Text">insert_nested_uuid_manual</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_nested_uuid_manual">
+        <output-dir compare="Text">upsert_nested_uuid_manual</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="insert_nested_uuid_manual_exists">
+        <output-dir compare="Text">insert_nested_uuid_manual_exists</output-dir>
+        <expected-error>Inserting duplicate keys into the primary storage</expected-error>
+        <source-location>false</source-location>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_nested_uuid_manual_exists">
+        <output-dir compare="Text">upsert_nested_uuid_manual_exists</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="insert_nested_uuid_manual_exists_select">
+        <output-dir compare="Text">insert_nested_uuid_manual_exists_select</output-dir>
+        <expected-error>Inserting duplicate keys into the primary storage</expected-error>
+        <source-location>false</source-location>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
+      <compilation-unit name="upsert_nested_uuid_manual_exists_select">
+        <output-dir compare="Text">upsert_nested_uuid_manual_exists_select</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="dml">
       <compilation-unit name="insert-with-bad-return">
         <output-dir compare="Text">insert-with-bad-return</output-dir>
         <expected-error>A returning expression cannot contain dataset access</expected-error>
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
index 23ef0ca..d69b6f1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
@@ -254,6 +254,8 @@ public class BuiltinFunctions {
     // objects
     public static final FunctionIdentifier RECORD_MERGE =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "object-merge", 2);
+    public static final FunctionIdentifier RECORD_MERGE_IGNORE_DUPLICATES =
+            new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "object-merge-ignore-duplicates", 2);
     public static final FunctionIdentifier RECORD_CONCAT =
             new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "object-concat", FunctionIdentifier.VARARGS);
     public static final FunctionIdentifier RECORD_CONCAT_STRICT =
@@ -2191,6 +2193,7 @@ public class BuiltinFunctions {
 
         // objects
         addFunction(RECORD_MERGE, RecordMergeTypeComputer.INSTANCE, true);
+        addPrivateFunction(RECORD_MERGE_IGNORE_DUPLICATES, RecordMergeTypeComputer.INSTANCE_IGNORE_DUPLICATES, true);
         addFunction(RECORD_CONCAT, OpenARecordTypeComputer.INSTANCE, true);
         addPrivateFunction(RECORD_CONCAT_STRICT, OpenARecordTypeComputer.INSTANCE, true);
         addFunction(ADD_FIELDS, RecordAddFieldsTypeComputer.INSTANCE, true);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
index 109f7c6..b1e4021 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
@@ -42,11 +42,16 @@ import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class RecordMergeTypeComputer implements IResultTypeComputer {
-    public static final RecordMergeTypeComputer INSTANCE = new RecordMergeTypeComputer();
 
-    private RecordMergeTypeComputer() {
+    public static final RecordMergeTypeComputer INSTANCE = new RecordMergeTypeComputer(false);
+    public static final RecordMergeTypeComputer INSTANCE_IGNORE_DUPLICATES = new RecordMergeTypeComputer(true);
+
+    private RecordMergeTypeComputer(boolean isIgnoreDuplicates) {
+        this.isIgnoreDuplicates = isIgnoreDuplicates;
     }
 
+    private final boolean isIgnoreDuplicates;
+
     @Override
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
@@ -85,22 +90,38 @@ public class RecordMergeTypeComputer implements IResultTypeComputer {
 
         List<String> additionalFieldNames = new ArrayList<>();
         List<IAType> additionalFieldTypes = new ArrayList<>();
-        String fieldNames[] = recType1.getFieldNames();
-        IAType fieldTypes[] = recType1.getFieldTypes();
+        String[] fieldNames = recType1.getFieldNames();
+        IAType[] fieldTypes = recType1.getFieldTypes();
         for (int i = 0; i < fieldNames.length; ++i) {
+
+            // For each field on the right record, we check if a field with matching name exists on the left record
             int pos = Collections.binarySearch(resultFieldNames, fieldNames[i]);
             if (pos >= 0) {
+
+                // If we're here, it means we found 2 fields with a matching field name
                 IAType resultFieldType = resultFieldTypes.get(pos);
+
+                // This is for fields with matching names, but different type tags.
                 if (resultFieldType.getTypeTag() != fieldTypes[i].getTypeTag()) {
-                    throw new CompilationException(ErrorCode.COMPILATION_DUPLICATE_FIELD_NAME, f.getSourceLocation(),
-                            fieldNames[i]);
+
+                    // If the ignore duplicates flag is set, we ignore the duplicate fields on the right record
+                    if (isIgnoreDuplicates) {
+                        continue;
+                    }
+                    // If the ignore duplicates flag is not set, we throw a duplicate field exception
+                    else {
+                        throw new CompilationException(ErrorCode.COMPILATION_DUPLICATE_FIELD_NAME,
+                                f.getSourceLocation(), fieldNames[i]);
+                    }
                 }
-                // Assuming fieldTypes[i].getTypeTag() = resultFieldType.getTypeTag()
+
+                // This is for fields with matching names, matching types, type ARecord, do nested merge
                 if (fieldTypes[i].getTypeTag() == ATypeTag.OBJECT) {
                     resultFieldTypes.set(pos,
                             mergedNestedType(fieldNames[i], fieldTypes[i], resultFieldType, f.getSourceLocation()));
                 }
             } else {
+                // If no field was found with a matching name, we simply add the field to be merged
                 additionalFieldNames.add(fieldNames[i]);
                 additionalFieldTypes.add(fieldTypes[i]);
             }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
index 45a85b2..bc297bf 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
@@ -18,43 +18,20 @@
  */
 package org.apache.asterix.runtime.evaluators.functions.records;
 
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.asterix.builders.RecordBuilder;
 import org.apache.asterix.common.annotations.MissingNullInOutFunction;
-import org.apache.asterix.common.exceptions.ErrorCode;
-import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.functions.IFunctionTypeInferer;
-import org.apache.asterix.om.pointables.ARecordVisitablePointable;
-import org.apache.asterix.om.pointables.PointableAllocator;
-import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
-import org.apache.asterix.om.pointables.base.IVisitablePointable;
 import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.asterix.runtime.evaluators.comparisons.DeepEqualAssessor;
-import org.apache.asterix.runtime.evaluators.functions.PointableHelper;
 import org.apache.asterix.runtime.functions.FunctionTypeInferers;
 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;
-import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.accessors.UTF8StringBinaryComparatorFactory;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.VoidPointable;
-import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 /**
  * record merge evaluator is used to combine two records with no matching fieldnames
@@ -82,15 +59,13 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
     };
 
     private static final long serialVersionUID = 1L;
-    private ARecordType outRecType;
-    private ARecordType inRecType0;
-    private ARecordType inRecType1;
+    private final IAType[] argTypes = new IAType[3];
 
     @Override
     public void setImmutableStates(Object... states) {
-        outRecType = TypeComputeUtils.extractRecordType((IAType) states[0]);
-        inRecType0 = TypeComputeUtils.extractRecordType((IAType) states[1]);
-        inRecType1 = TypeComputeUtils.extractRecordType((IAType) states[2]);
+        argTypes[0] = TypeComputeUtils.extractRecordType((IAType) states[0]);
+        argTypes[1] = TypeComputeUtils.extractRecordType((IAType) states[1]);
+        argTypes[2] = TypeComputeUtils.extractRecordType((IAType) states[2]);
     }
 
     @Override
@@ -100,156 +75,7 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                final PointableAllocator pa = new PointableAllocator();
-                final IVisitablePointable vp0 = pa.allocateRecordValue(inRecType0);
-                final IVisitablePointable vp1 = pa.allocateRecordValue(inRecType1);
-
-                final IPointable argPtr0 = new VoidPointable();
-                final IPointable argPtr1 = new VoidPointable();
-
-                final IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
-                final IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
-
-                final List<RecordBuilder> rbStack = new ArrayList<>();
-
-                final ArrayBackedValueStorage tabvs = new ArrayBackedValueStorage();
-                final IBinaryComparator stringBinaryComparator =
-                        UTF8StringBinaryComparatorFactory.INSTANCE.createBinaryComparator();
-
-                return new IScalarEvaluator() {
-
-                    private final RuntimeRecordTypeInfo runtimeRecordTypeInfo = new RuntimeRecordTypeInfo();
-                    private final DeepEqualAssessor deepEqualAssesor = new DeepEqualAssessor();
-                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
-                    private DataOutput out = resultStorage.getDataOutput();
-
-                    @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
-                        resultStorage.reset();
-                        eval0.evaluate(tuple, argPtr0);
-                        eval1.evaluate(tuple, argPtr1);
-
-                        if (PointableHelper.checkAndSetMissingOrNull(result, argPtr0, argPtr1)) {
-                            return;
-                        }
-
-                        vp0.set(argPtr0);
-                        vp1.set(argPtr1);
-
-                        ARecordVisitablePointable rp0 = (ARecordVisitablePointable) vp0;
-                        ARecordVisitablePointable rp1 = (ARecordVisitablePointable) vp1;
-
-                        try {
-                            mergeFields(outRecType, rp0, rp1, true, 0);
-                            rbStack.get(0).write(out, true);
-                        } catch (IOException e) {
-                            throw HyracksDataException.create(e);
-                        }
-                        result.set(resultStorage);
-                    }
-
-                    private void mergeFields(ARecordType combinedType, ARecordVisitablePointable leftRecord,
-                            ARecordVisitablePointable rightRecord, boolean openFromParent, int nestedLevel)
-                            throws IOException {
-                        if (rbStack.size() < (nestedLevel + 1)) {
-                            rbStack.add(new RecordBuilder());
-                        }
-
-                        rbStack.get(nestedLevel).reset(combinedType);
-                        rbStack.get(nestedLevel).init();
-
-                        //Add all fields from left record
-                        for (int i = 0; i < leftRecord.getFieldNames().size(); i++) {
-                            IVisitablePointable leftName = leftRecord.getFieldNames().get(i);
-                            IVisitablePointable leftValue = leftRecord.getFieldValues().get(i);
-                            IVisitablePointable leftType = leftRecord.getFieldTypeTags().get(i);
-                            boolean foundMatch = false;
-                            for (int j = 0; j < rightRecord.getFieldNames().size(); j++) {
-                                IVisitablePointable rightName = rightRecord.getFieldNames().get(j);
-                                IVisitablePointable rightValue = rightRecord.getFieldValues().get(j);
-                                IVisitablePointable rightType = rightRecord.getFieldTypeTags().get(j);
-                                // Check if same fieldname
-                                if (PointableHelper.isEqual(leftName, rightName, stringBinaryComparator)
-                                        && !deepEqualAssesor.isEqual(leftValue, rightValue)) {
-                                    //Field was found on the right and are subrecords, merge them
-                                    if (PointableHelper.sameType(ATypeTag.OBJECT, rightType)
-                                            && PointableHelper.sameType(ATypeTag.OBJECT, leftType)) {
-                                        //We are merging two sub records
-                                        addFieldToSubRecord(combinedType, leftName, leftValue, rightValue,
-                                                openFromParent, nestedLevel);
-                                        foundMatch = true;
-                                    } else {
-                                        throw new RuntimeDataException(ErrorCode.DUPLICATE_FIELD_NAME, getIdentifier());
-                                    }
-                                }
-                            }
-                            if (!foundMatch) {
-                                addFieldToSubRecord(combinedType, leftName, leftValue, null, openFromParent,
-                                        nestedLevel);
-                            }
-
-                        }
-                        //Repeat for right side (ignoring duplicates this time)
-                        for (int j = 0; j < rightRecord.getFieldNames().size(); j++) {
-                            IVisitablePointable rightName = rightRecord.getFieldNames().get(j);
-                            IVisitablePointable rightValue = rightRecord.getFieldValues().get(j);
-                            boolean foundMatch = false;
-                            for (int i = 0; i < leftRecord.getFieldNames().size(); i++) {
-                                IVisitablePointable leftName = leftRecord.getFieldNames().get(i);
-                                if (rightName.equals(leftName)) {
-                                    foundMatch = true;
-                                }
-                            }
-                            if (!foundMatch) {
-                                addFieldToSubRecord(combinedType, rightName, rightValue, null, openFromParent,
-                                        nestedLevel);
-                            }
-                        }
-                    }
-
-                    /*
-                     * Takes in a record type, field name, and the field values (which are record) from two records
-                     * Merges them into one record of combinedType
-                     * And adds that record as a field to the Record in subrb
-                     * the second value can be null, indicated that you just add the value of left as a field to subrb
-                     *
-                     */
-                    private void addFieldToSubRecord(ARecordType combinedType, IVisitablePointable fieldNamePointable,
-                            IVisitablePointable leftValue, IVisitablePointable rightValue, boolean openFromParent,
-                            int nestedLevel) throws IOException {
-
-                        runtimeRecordTypeInfo.reset(combinedType);
-                        int pos = runtimeRecordTypeInfo.getFieldIndex(fieldNamePointable.getByteArray(),
-                                fieldNamePointable.getStartOffset() + 1, fieldNamePointable.getLength() - 1);
-
-                        //Add the merged field
-                        if (combinedType != null && pos >= 0) {
-                            if (rightValue == null) {
-                                rbStack.get(nestedLevel).addField(pos, leftValue);
-                            } else {
-                                mergeFields((ARecordType) combinedType.getFieldTypes()[pos],
-                                        (ARecordVisitablePointable) leftValue, (ARecordVisitablePointable) rightValue,
-                                        false, nestedLevel + 1);
-
-                                tabvs.reset();
-                                rbStack.get(nestedLevel + 1).write(tabvs.getDataOutput(), true);
-                                rbStack.get(nestedLevel).addField(pos, tabvs);
-                            }
-                        } else {
-                            if (rightValue == null) {
-                                rbStack.get(nestedLevel).addField(fieldNamePointable, leftValue);
-                            } else {
-                                mergeFields(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE,
-                                        (ARecordVisitablePointable) leftValue, (ARecordVisitablePointable) rightValue,
-                                        false, nestedLevel + 1);
-                                tabvs.reset();
-                                rbStack.get(nestedLevel + 1).write(tabvs.getDataOutput(), true);
-                                rbStack.get(nestedLevel).addField(fieldNamePointable, tabvs);
-                            }
-                        }
-                    }
-
-                };
+                return new RecordMergeEvaluator(ctx, args, argTypes, sourceLoc, getIdentifier(), false);
             }
         };
     }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java
new file mode 100644
index 0000000..797b4c1
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeEvaluator.java
@@ -0,0 +1,240 @@
+/*
+ * 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.records;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.builders.RecordBuilder;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
+import org.apache.asterix.om.pointables.ARecordVisitablePointable;
+import org.apache.asterix.om.pointables.PointableAllocator;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.pointables.base.IVisitablePointable;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
+import org.apache.asterix.runtime.evaluators.comparisons.DeepEqualAssessor;
+import org.apache.asterix.runtime.evaluators.functions.AbstractScalarEval;
+import org.apache.asterix.runtime.evaluators.functions.PointableHelper;
+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;
+import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.data.std.accessors.UTF8StringBinaryComparatorFactory;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+/**
+ * record merge evaluator is used to combine two records with no matching fieldnames
+ * If both records have the same fieldname for a non-record field anywhere in the schema, the merge will fail
+ * This function is performed on a recursive level, meaning that nested records can be combined
+ * for instance if both records have a nested field called "metadata"
+ * where metadata from A is {"comments":"this rocks"} and metadata from B is {"index":7, "priority":5}
+ * Records A and B can be combined yielding a nested record called "metadata"
+ * That will have all three fields
+ */
+
+public class RecordMergeEvaluator extends AbstractScalarEval {
+
+    private final boolean isIgnoreDuplicates;
+
+    private final ARecordType outRecType;
+
+    private final IVisitablePointable vp0;
+    private final IVisitablePointable vp1;
+
+    private final IPointable argPtr0 = new VoidPointable();
+    private final IPointable argPtr1 = new VoidPointable();
+
+    private final IScalarEvaluator eval0;
+    private final IScalarEvaluator eval1;
+
+    private final List<RecordBuilder> rbStack = new ArrayList<>();
+
+    private final ArrayBackedValueStorage tabvs = new ArrayBackedValueStorage();
+    private final IBinaryComparator stringBinaryComparator =
+            UTF8StringBinaryComparatorFactory.INSTANCE.createBinaryComparator();
+
+    private final RuntimeRecordTypeInfo runtimeRecordTypeInfo = new RuntimeRecordTypeInfo();
+    private final DeepEqualAssessor deepEqualAssessor = new DeepEqualAssessor();
+    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+    private DataOutput out = resultStorage.getDataOutput();
+
+    RecordMergeEvaluator(IHyracksTaskContext ctx, IScalarEvaluatorFactory[] args, IAType[] argTypes,
+            SourceLocation sourceLocation, FunctionIdentifier identifier, boolean isIgnoreDuplicates)
+            throws HyracksDataException {
+        super(sourceLocation, identifier);
+
+        this.isIgnoreDuplicates = isIgnoreDuplicates;
+
+        eval0 = args[0].createScalarEvaluator(ctx);
+        eval1 = args[1].createScalarEvaluator(ctx);
+
+        outRecType = (ARecordType) argTypes[0];
+        ARecordType inRecType0 = (ARecordType) argTypes[1];
+        ARecordType inRecType1 = (ARecordType) argTypes[2];
+
+        PointableAllocator pa = new PointableAllocator();
+        vp0 = pa.allocateRecordValue(inRecType0);
+        vp1 = pa.allocateRecordValue(inRecType1);
+    }
+
+    @Override
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
+        resultStorage.reset();
+        eval0.evaluate(tuple, argPtr0);
+        eval1.evaluate(tuple, argPtr1);
+
+        if (PointableHelper.checkAndSetMissingOrNull(result, argPtr0, argPtr1)) {
+            return;
+        }
+
+        vp0.set(argPtr0);
+        vp1.set(argPtr1);
+
+        ARecordVisitablePointable rp0 = (ARecordVisitablePointable) vp0;
+        ARecordVisitablePointable rp1 = (ARecordVisitablePointable) vp1;
+
+        try {
+            mergeFields(outRecType, rp0, rp1, 0);
+            rbStack.get(0).write(out, true);
+        } catch (IOException e) {
+            throw HyracksDataException.create(e);
+        }
+        result.set(resultStorage);
+    }
+
+    private void mergeFields(ARecordType combinedType, ARecordVisitablePointable leftRecord,
+            ARecordVisitablePointable rightRecord, int nestedLevel) throws IOException {
+        if (rbStack.size() < (nestedLevel + 1)) {
+            rbStack.add(new RecordBuilder());
+        }
+
+        rbStack.get(nestedLevel).reset(combinedType);
+        rbStack.get(nestedLevel).init();
+
+        // Add all fields from left record
+        for (int i = 0; i < leftRecord.getFieldNames().size(); i++) {
+            IVisitablePointable leftName = leftRecord.getFieldNames().get(i);
+            IVisitablePointable leftValue = leftRecord.getFieldValues().get(i);
+            IVisitablePointable leftType = leftRecord.getFieldTypeTags().get(i);
+
+            // Check if a match for the left record exists on the right record
+            boolean foundMatch = false;
+            for (int j = 0; j < rightRecord.getFieldNames().size(); j++) {
+                IVisitablePointable rightName = rightRecord.getFieldNames().get(j);
+                IVisitablePointable rightValue = rightRecord.getFieldValues().get(j);
+                IVisitablePointable rightType = rightRecord.getFieldTypeTags().get(j);
+
+                // Check if same field name and not same value exists (same name and value, just take the left one)
+                if (PointableHelper.isEqual(leftName, rightName, stringBinaryComparator)
+                        && !deepEqualAssessor.isEqual(leftValue, rightValue)) {
+
+                    // Same name, different value, both of type Record, do nested join
+                    if (PointableHelper.sameType(ATypeTag.OBJECT, rightType)
+                            && PointableHelper.sameType(ATypeTag.OBJECT, leftType)) {
+                        // We are merging two sub records
+                        addFieldToSubRecord(combinedType, leftName, leftValue, rightValue, nestedLevel);
+                        foundMatch = true;
+                    }
+                    // Same name, different value, not of type Record, handle duplicate field
+                    else {
+                        // Ignore and take left field if ignore duplicate flag is true, otherwise, throw an exception
+                        if (!isIgnoreDuplicates) {
+                            throw new RuntimeDataException(ErrorCode.DUPLICATE_FIELD_NAME, functionIdentifier);
+                        }
+                    }
+                }
+            }
+
+            // If no match is found, we add the left field
+            if (!foundMatch) {
+                addFieldToSubRecord(combinedType, leftName, leftValue, null, nestedLevel);
+            }
+
+        }
+
+        // Repeat for right side (ignoring duplicates this time, all duplicates were handled on the previous step)
+        for (int j = 0; j < rightRecord.getFieldNames().size(); j++) {
+            IVisitablePointable rightName = rightRecord.getFieldNames().get(j);
+            IVisitablePointable rightValue = rightRecord.getFieldValues().get(j);
+            boolean foundMatch = false;
+            for (int i = 0; i < leftRecord.getFieldNames().size(); i++) {
+                IVisitablePointable leftName = leftRecord.getFieldNames().get(i);
+                if (rightName.equals(leftName)) {
+                    foundMatch = true;
+                }
+            }
+
+            // If no match is found, we add the right field
+            if (!foundMatch) {
+                addFieldToSubRecord(combinedType, rightName, rightValue, null, nestedLevel);
+            }
+        }
+    }
+
+    /*
+     * Takes in a record type, field name, and the field values (which are record) from two records
+     * Merges them into one record of combinedType
+     * And adds that record as a field to the Record in subrb
+     * the second value can be null, indicated that you just add the value of left as a field to subrb
+     *
+     */
+    private void addFieldToSubRecord(ARecordType combinedType, IVisitablePointable fieldNamePointable,
+            IVisitablePointable leftValue, IVisitablePointable rightValue, int nestedLevel) throws IOException {
+
+        runtimeRecordTypeInfo.reset(combinedType);
+        int pos = runtimeRecordTypeInfo.getFieldIndex(fieldNamePointable.getByteArray(),
+                fieldNamePointable.getStartOffset() + 1, fieldNamePointable.getLength() - 1);
+
+        //Add the merged field
+        if (combinedType != null && pos >= 0) {
+            if (rightValue == null) {
+                rbStack.get(nestedLevel).addField(pos, leftValue);
+            } else {
+                mergeFields((ARecordType) combinedType.getFieldTypes()[pos], (ARecordVisitablePointable) leftValue,
+                        (ARecordVisitablePointable) rightValue, nestedLevel + 1);
+
+                tabvs.reset();
+                rbStack.get(nestedLevel + 1).write(tabvs.getDataOutput(), true);
+                rbStack.get(nestedLevel).addField(pos, tabvs);
+            }
+        } else {
+            if (rightValue == null) {
+                rbStack.get(nestedLevel).addField(fieldNamePointable, leftValue);
+            } else {
+                mergeFields(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, (ARecordVisitablePointable) leftValue,
+                        (ARecordVisitablePointable) rightValue, nestedLevel + 1);
+                tabvs.reset();
+                rbStack.get(nestedLevel + 1).write(tabvs.getDataOutput(), true);
+                rbStack.get(nestedLevel).addField(fieldNamePointable, tabvs);
+            }
+        }
+    }
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeIgnoreDuplicatesDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeIgnoreDuplicatesDescriptor.java
new file mode 100644
index 0000000..dc5288d
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeIgnoreDuplicatesDescriptor.java
@@ -0,0 +1,96 @@
+/*
+ * 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.records;
+
+import org.apache.asterix.common.annotations.MissingNullInOutFunction;
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.functions.IFunctionTypeInferer;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
+import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.functions.FunctionTypeInferers;
+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;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+/**
+ * The record merge ignore duplicates differs from the normal record merging in the following scenarios:
+ * - When 2 fields have matching names, but different values, left record field will be taken.
+ * - When 2 fields have matching names, but different types, left record field will be taken.
+ *
+ * Examples:
+ * - Matching field name, type and value
+ * - normal merge: {id: 1}, {id: 1} -> {id: 1}
+ * - ignore merge: {id: 1}, {id: 1} -> {id: 1}
+ *
+ * - Matching field name, type, different value
+ * - normal merge: {id: 1}, {id: 2} -> duplicate field exception (mismatched value)
+ * - ignore merge: {id: 1}, {id: 2} -> {id: 1} (mismatched values are ignored, left record field is taken)
+ *
+ * - Matching field name, different type
+ * - normal merge: {id: 1}, {id: "1"} -> duplicate field exception (mismatched type)
+ * - ignore merge: {id: 1}, {id: "1"} -> {id: 1} (mismatched types are ignored, left record field is taken)
+ */
+
+@MissingNullInOutFunction
+public class RecordMergeIgnoreDuplicatesDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new RecordMergeIgnoreDuplicatesDescriptor();
+        }
+
+        @Override
+        public IFunctionTypeInferer createFunctionTypeInferer() {
+            return new FunctionTypeInferers.RecordMergeTypeInferer();
+        }
+    };
+
+    private static final long serialVersionUID = 1L;
+    private final IAType[] argTypes = new IAType[3];
+
+    @Override
+    public void setImmutableStates(Object... states) {
+        argTypes[0] = TypeComputeUtils.extractRecordType((IAType) states[0]);
+        argTypes[1] = TypeComputeUtils.extractRecordType((IAType) states[1]);
+        argTypes[2] = TypeComputeUtils.extractRecordType((IAType) states[2]);
+    }
+
+    @Override
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+        return new IScalarEvaluatorFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
+                return new RecordMergeEvaluator(ctx, args, argTypes, sourceLoc, getIdentifier(), true);
+            }
+        };
+    }
+
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return BuiltinFunctions.RECORD_MERGE_IGNORE_DUPLICATES;
+    }
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
index be4937e..13af5a1 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionCollection.java
@@ -452,6 +452,7 @@ import org.apache.asterix.runtime.evaluators.functions.records.RecordConcatDescr
 import org.apache.asterix.runtime.evaluators.functions.records.RecordConcatStrictDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.records.RecordLengthDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.records.RecordMergeDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.records.RecordMergeIgnoreDuplicatesDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.records.RecordNamesDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.records.RecordPairsDescriptor;
 import org.apache.asterix.runtime.evaluators.functions.records.RecordPutDescriptor;
@@ -1002,6 +1003,7 @@ public final class FunctionCollection implements IFunctionCollection {
         fc.add(GetRecordFieldValueDescriptor.FACTORY);
         fc.add(DeepEqualityDescriptor.FACTORY);
         fc.add(RecordMergeDescriptor.FACTORY);
+        fc.add(RecordMergeIgnoreDuplicatesDescriptor.FACTORY);
         fc.add(RecordAddFieldsDescriptor.FACTORY);
         fc.add(RecordRemoveFieldsDescriptor.FACTORY);
         fc.add(RecordLengthDescriptor.FACTORY);