asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "abdullah alamoudi (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [NO ISSUE][SQL] Change merge policy syntax
Date Wed, 29 Nov 2017 05:34:43 GMT
abdullah alamoudi has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2183

Change subject: [NO ISSUE][SQL] Change merge policy syntax
......................................................................

[NO ISSUE][SQL] Change merge policy syntax

- user model changes: yes
  - change the way a merge policy is specified
- storage format changes: no
- interface changes: no

details:
- previously, merge policies are specified as follows:
  <USING> <COMPACTION> <POLICY>
  prefix_merge (("number"="123"),("size"="456"));
- After this change, the policies are specified as:
  <WITH> {"compaction policy":
           {"name": "prefix_merge", "parameters":
            {"number": 123,"size": 456}
           }
         };

- compaction and policy are not key words anymore

Change-Id: I040f4c74cfa0170b8888128ad5f975e196658776
---
M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/delete/delete.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/upsert/upsert.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-08/fulltext-08.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries/upsert/primary-correlated-secondary-btree/primary-correlated-secondary-btree.1.ddl.aql
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-open/scan-delete-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index/scan-delete-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-nullable/scan-delete-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-open/scan-delete-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index/scan-delete-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-nullable/scan-delete-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-open/scan-delete-rtree-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index/scan-delete-rtree-correlated-secondary-index.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-open/scan-insert-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index/scan-insert-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-nullable/scan-insert-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-open/scan-insert-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index/scan-insert-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-nullable/scan-insert-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-open/scan-insert-rtree-correlated-secondary-index-open.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index/scan-insert-rtree-correlated-secondary-index.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/delete/delete.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-ngram/insert-with-correlated-secondary-inverted-ngram.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-word/insert-with-correlated-secondary-inverted-word.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-rtree/insert-with-correlated-secondary-rtree.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
M asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
M asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
A asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
A asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/MergePolicyUtils.java
75 files changed, 1,332 insertions(+), 261 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/83/2183/1

diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 2fc3258..1eddc6b 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -86,6 +86,7 @@
 import org.apache.asterix.lang.common.base.IStatementRewriter;
 import org.apache.asterix.lang.common.base.Statement;
 import org.apache.asterix.lang.common.expression.IndexedTypeExpression;
+import org.apache.asterix.lang.common.expression.RecordConstructor;
 import org.apache.asterix.lang.common.statement.CompactStatement;
 import org.apache.asterix.lang.common.statement.ConnectFeedStatement;
 import org.apache.asterix.lang.common.statement.CreateDataverseStatement;
@@ -2873,13 +2874,13 @@
             this.handleDatasetDropStatement(metadataProvider, dropStmt, hcc, null);
             IDatasetDetailsDecl idd = new InternalDetailsDecl(toIndex.getKeyFieldNames(),
                     toIndex.getKeyFieldSourceIndicators(), false, null);
+            RecordConstructor withRecord = getWithRecord(toDataset);
             DatasetDecl createToDataset = new DatasetDecl(new Identifier(dataverseNameTo),
                     pregelixStmt.getDatasetNameTo(), new Identifier(toDataset.getItemTypeDataverseName()),
                     new Identifier(toDataset.getItemTypeName()),
                     new Identifier(toDataset.getMetaItemTypeDataverseName()),
                     new Identifier(toDataset.getMetaItemTypeName()), new Identifier(toDataset.getNodeGroupName()),
-                    toDataset.getCompactionPolicy(), toDataset.getCompactionPolicyProperties(), toDataset.getHints(),
-                    toDataset.getDatasetType(), idd, false);
+                    toDataset.getHints(), toDataset.getDatasetType(), idd, withRecord, false);
             this.handleCreateDatasetStatement(metadataProvider, createToDataset, hcc, null);
         } catch (Exception e) {
             LOGGER.log(Level.WARNING, e.getMessage(), e);
@@ -2890,6 +2891,10 @@
         FlushDatasetUtil.flushDataset(hcc, metadataProvider, dataverseNameFrom, datasetNameFrom);
     }
 
+    private static RecordConstructor getWithRecord(Dataset dataset) {
+        return null;
+    }
+
     // Executes external shell commands.
     protected int executeExternalShellProgram(ProcessBuilder pb)
             throws IOException, AlgebricksException, InterruptedException {
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.aql
index e4a402e..b8b87e1 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.aql
@@ -45,8 +45,12 @@
 }
 
 create dataset Customers(CustomerType) primary key cid
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed CustomerFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.aql
index c540b1f..e426fd4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.aql
@@ -53,9 +53,17 @@
 }
 
 create dataset Customers(CustomerType) primary key cid
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create dataset CustomersOpen(CustomerOpenType) primary key cid
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.aql
index c846c06..7d49af8 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.aql
@@ -45,10 +45,17 @@
 }
 
 create dataset Customers(CustomerType) primary key cid
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create dataset CustomersMini(CustomerType) primary key cid
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
-
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.aql
index 09e4d94..0dfd276 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.aql
@@ -53,10 +53,17 @@
 }
 
 create dataset Customers(CustomerType) primary key cid
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create dataset CustomersOpen(CustomerOpenType) primary key cid
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
-
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.aql
index f5360a4..3101670 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.aql
@@ -49,6 +49,9 @@
 }
 
 create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber using compaction policy constant
-(("num-components"="2"));
-
+primary key l_orderkey, l_linenumber
+with {"merge policy":
+       {"name":"constant", "parameters":
+         {"num-components":2}
+       }
+     };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.aql
index ab50500..713eb04 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.aql
@@ -49,8 +49,13 @@
 }
 
 create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber using compaction policy correlated-prefix
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+primary key l_orderkey, l_linenumber
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed LineItemFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.aql
index 37a7374..6fdaa5e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.aql
@@ -49,6 +49,10 @@
 }
 
 create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber using compaction policy correlated-prefix
-(("max-mergable-component-size"="1048576"),("max-tolerance-component-count"="3"));
-
+primary key l_orderkey, l_linenumber
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":1048576, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.aql
index 5b335e0..b863daf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.aql
@@ -49,5 +49,5 @@
 }
 
 create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber using compaction policy no-merge;
+primary key l_orderkey, l_linenumber with {"merge policy":{"name":"no-merge"}};
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.aql
index 80a5d68..a336f46 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.aql
@@ -49,6 +49,10 @@
 }
 
 create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber using compaction policy prefix
-(("max-mergable-component-size"="1048576"),("max-tolerance-component-count"="3"));
-
+primary key l_orderkey, l_linenumber
+with {"merge policy":
+       {"name":"prefix", "parameters":
+         {"max-mergable-component-size":1048576, "max-tolerance-component-count":3
+         }
+       }
+     };  
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/delete/delete.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/delete/delete.1.ddl.aql
index 70af710..3bc8ff4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/delete/delete.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/delete/delete.1.ddl.aql
@@ -81,8 +81,13 @@
 }
 
 create dataset Tweet(typeTweet) primary key id
-using compaction policy prefix (("max-mergable-component-size"="32768"),("max-tolerance-component-count"="32"))
-with filter on create_at;
+with filter on create_at
+with {"merge policy":
+       {"name":"prefix", "parameters":
+         {"max-mergable-component-size":32768, "max-tolerance-component-count":32
+         }
+       }
+     };
 
 create index text_idx if not exists on Tweet("text") type fulltext;
 create index state_idx if not exists on Tweet(geo_tag.stateID) type btree;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/upsert/upsert.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/upsert/upsert.1.ddl.aql
index 4adc491..db560ec 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/upsert/upsert.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/upsert/upsert.1.ddl.aql
@@ -81,8 +81,13 @@
 }
 
 create dataset Tweet(typeTweet) primary key id
-using compaction policy prefix (("max-mergable-component-size"="32768"),("max-tolerance-component-count"="32"))
-with filter on create_at;
+with filter on create_at
+with {"merge policy":
+       {"name":"prefix", "parameters":
+         {"max-mergable-component-size":32768, "max-tolerance-component-count":32
+         }
+       }
+     };
 
 create index text_idx if not exists on Tweet("text") type btree;
 create index state_idx if not exists on Tweet(geo_tag.stateID) type btree;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-08/fulltext-08.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-08/fulltext-08.1.ddl.aql
index b6732c4..f302344 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-08/fulltext-08.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-08/fulltext-08.1.ddl.aql
@@ -82,4 +82,10 @@
     geo_tag: typeGeoTag
 }
 create dataset ds_tweet(typeTweet) if not exists primary key id
-using compaction policy prefix (("max-mergable-component-size"="134217728"),("max-tolerance-component-count"="10")) with filter on create_at;
+with filter on create_at
+with {"merge policy":
+       {"name":"prefix", "parameters":
+         {"max-mergable-component-size":134217728, "max-tolerance-component-count":10
+         }
+       }
+     };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/upsert/primary-correlated-secondary-btree/primary-correlated-secondary-btree.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/upsert/primary-correlated-secondary-btree/primary-correlated-secondary-btree.1.ddl.aql
index 5bb3985..0455a1c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/upsert/primary-correlated-secondary-btree/primary-correlated-secondary-btree.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/upsert/primary-correlated-secondary-btree/primary-correlated-secondary-btree.1.ddl.aql
@@ -34,9 +34,17 @@
 };
 
 create dataset UpsertTo("TestType") primary key id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create dataset UpsertFrom("TestType") primary key id
-using compaction policy "correlated-prefix"
-(("max-mergable-component-size"="16384"),("max-tolerance-component-count"="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
index 43b3b0d..0ad1742 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-nullable/scan-delete-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -52,8 +52,12 @@
 };
 
 create dataset Customers(CustomerType) primary key cid
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 
 create feed CustomerFeed
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.sqlpp
index 4ede65d..5de4765 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-btree-correlated-secondary-index-open/scan-delete-btree-correlated-secondary-index-open.1.ddl.sqlpp
@@ -65,9 +65,17 @@
 };
 
 create dataset Customers(CustomerType) primary key cid
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset CustomersOpen(CustomerOpenType) primary key cid
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
index e79276a..58df2fc 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable/scan-delete-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -40,8 +40,12 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed DBLPFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-open/scan-delete-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-open/scan-delete-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
index 2b5788e..443d166 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-open/scan-delete-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index-open/scan-delete-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
@@ -47,10 +47,18 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLPOpen(DBLPOpenType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index/scan-delete-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index/scan-delete-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
index 9622774..769316b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index/scan-delete-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-ngram-correlated-secondary-index/scan-delete-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
@@ -39,8 +39,12 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed DBLPFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-nullable/scan-delete-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-nullable/scan-delete-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
index 4750e17..4076179 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-nullable/scan-delete-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-nullable/scan-delete-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -40,8 +40,12 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed DBLPFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-open/scan-delete-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-open/scan-delete-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
index 7a08dd2..d43b30c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-open/scan-delete-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index-open/scan-delete-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
@@ -48,10 +48,19 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLPOpen(DBLPOpenType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
+
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index/scan-delete-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index/scan-delete-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
index 4bb975e..a625ed2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index/scan-delete-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-inverted-index-word-correlated-secondary-index/scan-delete-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
@@ -39,8 +39,13 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
+
 
 create feed DBLPFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-nullable/scan-delete-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-nullable/scan-delete-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
index 3e1b6d5..4e4a21d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-nullable/scan-delete-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-nullable/scan-delete-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -43,8 +43,12 @@
 };
 
 create  dataset MyData(MyRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed MyFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-open/scan-delete-rtree-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-open/scan-delete-rtree-correlated-secondary-index-open.1.ddl.sqlpp
index cc505c2..4c2d66a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-open/scan-delete-rtree-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index-open/scan-delete-rtree-correlated-secondary-index-open.1.ddl.sqlpp
@@ -56,11 +56,19 @@
 };
 
 create  dataset MyData(MyRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset MyDataOpen(MyRecordOpen) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index/scan-delete-rtree-correlated-secondary-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index/scan-delete-rtree-correlated-secondary-index.1.ddl.sqlpp
index 00cdd5b..595dc13 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index/scan-delete-rtree-correlated-secondary-index.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-delete-rtree-correlated-secondary-index/scan-delete-rtree-correlated-secondary-index.1.ddl.sqlpp
@@ -44,9 +44,12 @@
 };
 
 create dataset MyData(MyRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
-
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed MyFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
index ef0237f..0fe6d80 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-nullable/scan-insert-btree-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -52,11 +52,19 @@
 };
 
 create  dataset Customers(CustomerType) primary key cid
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset CustomersMini(CustomerType) primary key cid
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.sqlpp
index d467308..21a0abd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-btree-correlated-secondary-index-open/scan-insert-btree-correlated-secondary-index-open.1.ddl.sqlpp
@@ -64,9 +64,17 @@
 };
 
 create  dataset Customers(CustomerType) primary key cid
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset CustomersOpen(CustomerOpenType) primary key cid
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
index c28e580..b709060 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable/scan-insert-inverted-index-ngram-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -40,11 +40,18 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLP1(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
-
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-open/scan-insert-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-open/scan-insert-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
index aaf1888..6f80c63 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-open/scan-insert-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index-open/scan-insert-inverted-index-ngram-correlated-secondary-index-open.1.ddl.sqlpp
@@ -48,10 +48,17 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLPOpen(DBLPOpenType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
-
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index/scan-insert-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index/scan-insert-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
index b788e1a..8571816 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index/scan-insert-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-ngram-correlated-secondary-index/scan-insert-inverted-index-ngram-correlated-secondary-index.1.ddl.sqlpp
@@ -39,10 +39,18 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLP1(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-nullable/scan-insert-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-nullable/scan-insert-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
index 61c8447..b6d51ce 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-nullable/scan-insert-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-nullable/scan-insert-inverted-index-word-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -40,10 +40,18 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLP1(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-open/scan-insert-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-open/scan-insert-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
index a858394..36a34ee 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-open/scan-insert-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index-open/scan-insert-inverted-index-word-correlated-secondary-index-open.1.ddl.sqlpp
@@ -48,10 +48,18 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLPOpen(DBLPOpenType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index/scan-insert-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index/scan-insert-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
index 1067c80..b9300da 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index/scan-insert-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-inverted-index-word-correlated-secondary-index/scan-insert-inverted-index-word-correlated-secondary-index.1.ddl.sqlpp
@@ -39,11 +39,19 @@
 };
 
 create  dataset DBLP(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset DBLP1(DBLPType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-nullable/scan-insert-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-nullable/scan-insert-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
index 849f7d1..ad146df 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-nullable/scan-insert-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-nullable/scan-insert-rtree-correlated-secondary-index-nullable.1.ddl.sqlpp
@@ -49,13 +49,21 @@
 };
 
 create  dataset MyData(MyRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 
 create  dataset MyMiniData(MyMiniRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed MyFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-open/scan-insert-rtree-correlated-secondary-index-open.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-open/scan-insert-rtree-correlated-secondary-index-open.1.ddl.sqlpp
index 510cc51..73d2a17 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-open/scan-insert-rtree-correlated-secondary-index-open.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index-open/scan-insert-rtree-correlated-secondary-index-open.1.ddl.sqlpp
@@ -49,12 +49,20 @@
 };
 
 create  dataset MyData(MyRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset MyOpenData(MyOpenRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed MyFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index/scan-insert-rtree-correlated-secondary-index.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index/scan-insert-rtree-correlated-secondary-index.1.ddl.sqlpp
index e986bb6..1a13231 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index/scan-insert-rtree-correlated-secondary-index.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/scan-insert-rtree-correlated-secondary-index/scan-insert-rtree-correlated-secondary-index.1.ddl.sqlpp
@@ -42,12 +42,20 @@
 };
 
 create  dataset MyData(MyRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset MyMiniData(MyMiniRecord) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed MyFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp
index 14b2ad1..ed344ea 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-constant-merge-policy/using-constant-merge-policy.1.ddl.sqlpp
@@ -50,5 +50,10 @@
   l_comment : string
 };
 
-create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy `constant`((`num-components`=`2`));
+create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber
+with {"merge policy":
+       {"name":"constant", "parameters":
+         {"num-components":2}
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.sqlpp
index 0acd01f..3412df3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy-with-feed/using-correlated-prefix-merge-policy-with-feed.1.ddl.sqlpp
@@ -49,8 +49,13 @@
 };
 
 create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+primary key l_orderkey, l_linenumber
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create feed LineItemFeed
 using localfs
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp
index 9fb610e..bfbdc90 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-correlated-prefix-merge-policy/using-correlated-prefix-merge-policy.1.ddl.sqlpp
@@ -50,5 +50,11 @@
   l_comment : string
 };
 
-create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy `correlated-prefix`((`max-mergable-component-size`=`1048576`),(`max-tolerance-component-count`=`3`));
+create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":1048576, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp
index 8ea402c..812c2d8 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-no-merge-policy/using-no-merge-policy.1.ddl.sqlpp
@@ -50,5 +50,5 @@
   l_comment : string
 };
 
-create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy `no-merge`;
+create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber with {"merge policy":{"name":"no-merge"}};
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp
index b04c631..d88d4f0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/dml/using-prefix-merge-policy/using-prefix-merge-policy.1.ddl.sqlpp
@@ -50,5 +50,10 @@
   l_comment : string
 };
 
-create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber using compaction policy `prefix`((`max-mergable-component-size`=`1048576`),(`max-tolerance-component-count`=`3`));
-
+create  dataset LineItem(LineItemType) primary key l_orderkey,l_linenumber
+with {"merge policy":
+       {"name":"prefix", "parameters":
+         {"max-mergable-component-size":1048576, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/delete/delete.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/delete/delete.1.ddl.sqlpp
index fcd4f57..201f876 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/delete/delete.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/delete/delete.1.ddl.sqlpp
@@ -81,8 +81,13 @@
 };
 
 create dataset Tweet(typeTweet) primary key id
-using compaction policy prefix (("max-mergable-component-size"="32768"),("max-tolerance-component-count"="32"))
-with filter on create_at;
+with filter on create_at
+with {"merge policy":
+       {"name":"prefix", "parameters":
+         {"max-mergable-component-size":32768, "max-tolerance-component-count":32
+         }
+       }
+     };
 
 create index text_idx if not exists on Tweet(`text`) type fulltext;
 create index state_idx if not exists on Tweet(geo_tag.stateID) type btree;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.sqlpp
index a76d678..69942b2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.sqlpp
@@ -39,10 +39,18 @@
 };
 
 create  dataset FacebookMessages(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset FacebookMessages2(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`))
- with filter on `send-time`;
+with filter on `send-time`
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-ngram/insert-with-correlated-secondary-inverted-ngram.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-ngram/insert-with-correlated-secondary-inverted-ngram.1.ddl.sqlpp
index abec9e5..66e836e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-ngram/insert-with-correlated-secondary-inverted-ngram.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-ngram/insert-with-correlated-secondary-inverted-ngram.1.ddl.sqlpp
@@ -39,11 +39,19 @@
 };
 
 create  dataset FacebookMessages(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset FacebookMessages2(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`))
-with filter on `send-time`;
+with filter on `send-time`
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-word/insert-with-correlated-secondary-inverted-word.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-word/insert-with-correlated-secondary-inverted-word.1.ddl.sqlpp
index d2eb504..6d00759 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-word/insert-with-correlated-secondary-inverted-word.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-inverted-word/insert-with-correlated-secondary-inverted-word.1.ddl.sqlpp
@@ -39,11 +39,19 @@
 };
 
 create  dataset FacebookMessages(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset FacebookMessages2(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`))
-with filter on `send-time`;
+with filter on `send-time`
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-rtree/insert-with-correlated-secondary-rtree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-rtree/insert-with-correlated-secondary-rtree.1.ddl.sqlpp
index 3727b9c..d8f3e12 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-rtree/insert-with-correlated-secondary-rtree.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/insert-with-correlated-secondary-rtree/insert-with-correlated-secondary-rtree.1.ddl.sqlpp
@@ -39,11 +39,19 @@
 };
 
 create  dataset FacebookMessages(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create  dataset FacebookMessages2(FacebookMessageType) primary key `message-id`
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`))
-with filter on `send-time`;
+with filter on `send-time`
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
index fd65d71..bb8a76e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/filters/upsert/upsert.1.ddl.sqlpp
@@ -82,8 +82,13 @@
 };
 
 create dataset Tweet(typeTweet) primary key id
-using compaction policy prefix (("max-mergable-component-size"="32768"),("max-tolerance-component-count"="32"))
-with filter on create_at;
+with filter on create_at
+with {"merge policy":
+       {"name":"prefix", "parameters":
+         {"max-mergable-component-size":32768, "max-tolerance-component-count":32
+         }
+       }
+     };
 
 create index text_idx if not exists on Tweet(`text`) type btree;
 create index state_idx if not exists on Tweet(geo_tag.stateID) type btree;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
index caa7ca4..42a81cb 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/correlated-index-selection/btree-index-01/btree-index-01.1.ddl.sqlpp
@@ -31,5 +31,9 @@
 
 create dataset TestOpen(TestOpenType)
 primary key c_id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`="16384"),(`max-tolerance-component-count`="3"));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
index 872e1bc..a195557 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/multiple-correlated-secondaries/multiple-correlated-secondaries.1.ddl.sqlpp
@@ -35,11 +35,19 @@
 
 create dataset UpsertTo(MyRecord)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 
 create dataset UpsertFrom(MyRecord)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
index d1db047..48bd7c9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-btree/primary-secondary-btree.1.ddl.sqlpp
@@ -34,9 +34,17 @@
 };
 
 create dataset UpsertTo(TestType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create dataset UpsertFrom(TestType) primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
index f54ab2b..483c28d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-inverted/primary-correlated-secondary-inverted.1.ddl.sqlpp
@@ -30,10 +30,18 @@
 
 create dataset UpsertToDBLP(DBLPType)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create dataset UpsertFromDBLP(DBLPType)
 primary key id
-using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
index cc33f84..d4c9528 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/upsert/primary-correlated-secondary-rtree/primary-correlated-secondary-rtree.1.ddl.sqlpp
@@ -33,11 +33,19 @@
 };
 
 create dataset UpsertTo(MyRecord)
- primary key id
- using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+primary key id
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
 
 create dataset UpsertFrom(MyRecord)
- primary key id
- using compaction policy `correlated-prefix`
-((`max-mergable-component-size`=`16384`),(`max-tolerance-component-count`=`3`));
+primary key id
+with {"merge policy":
+       {"name":"correlated-prefix", "parameters":
+         {"max-mergable-component-size":16384, "max-tolerance-component-count":3
+         }
+       }
+     };
\ No newline at end of file
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index a4cf64a..cf1daca 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -133,6 +133,11 @@
     public static final int COMPILATION_FAILED_DUE_TO_REPLICATE_OP = 1054;
     public static final int COMPILATION_INCOMPATIBLE_FUNCTION_LANGUAGE = 1055;
     public static final int TOO_MANY_OPTIONS_FOR_FUNCTION = 1056;
+    public static final int EXPRESSION_NOT_SUPPORTED_IN_CONSTANT_RECORD = 1057;
+    public static final int LITERAL_TYPE_NOT_SUPPORTED_IN_CONSTANT_RECORD = 1058;
+    public static final int WITH_FIELD_MUST_BE_OF_TYPE = 1059;
+    public static final int WITH_FIELD_MUST_CONTAIN_SUB_FIELD = 1060;
+    public static final int MERGE_POLICY_PARAMETER_INVALID_TYPE = 1061;
 
     // Feed errors
     public static final int DATAFLOW_ILLEGAL_STATE = 3001;
diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 39a74ff..51382a2 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -119,6 +119,11 @@
 1054 = Compilation failed due to some problem in the query plan.
 1055 = Incompatible function language. Expect %1$s, but %2$s found.
 1056 = Too many options were specified for %1$s
+1057 = Expression of type %1$s is not supported in constant record
+1058 = Literal of type %1$s is not supported in constant record
+1059 = Field %1$s in the with clause must be of type %2$s
+1060 = Field %1$s in the with clause must contain sub field %2$s
+1061 = Merge policy parameters cannot be of type %1$s
 
 # Feed Errors
 3001 = Illegal state.
diff --git a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
index 59ed8ae..5c7c6f2 100644
--- a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
+++ b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
@@ -440,16 +440,15 @@
   Pair<Identifier,Identifier> typeComponents = null;
   String adapterName = null;
   Map<String,String> properties = null;
-  Map<String,String> compactionPolicyProperties = null;
   FunctionSignature appliedFunction = null;
   Pair<List<Integer>, List<List<String>>> primaryKeyFields = null;
   String nodeGroupName = null;
   Map<String,String> hints = new HashMap<String,String>();
   DatasetDecl dsetDecl = null;
   boolean autogenerated = false;
-  String compactionPolicy = null;
   Pair<Integer, List<String>> filterField = null;
   Pair<Identifier,Identifier> metaTypeComponents = new Pair<Identifier, Identifier>(null, null);
+  RecordConstructor withRecord = null;
 }
 {
   (
@@ -459,24 +458,27 @@
     <USING> adapterName = AdapterName() properties = Configuration()
     ( <ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         ExternalDetailsDecl edd = new ExternalDetailsDecl();
         edd.setAdapter(adapterName);
         edd.setProperties(properties);
-        dsetDecl = new DatasetDecl(nameComponents.first,
-                                   nameComponents.second,
-                                   typeComponents.first,
-                                   typeComponents.second,
-                                   metaTypeComponents.first,
-                                   metaTypeComponents.second,
-                                   nodeGroupName != null? new Identifier(nodeGroupName): null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
-                                   hints,
-                                   DatasetType.EXTERNAL,
-                                   edd,
-                                   ifNotExists);
+        try{
+            dsetDecl = new DatasetDecl(nameComponents.first,
+              nameComponents.second,
+              typeComponents.first,
+              typeComponents.second,
+              metaTypeComponents.first,
+              metaTypeComponents.second,
+              nodeGroupName != null? new Identifier(nodeGroupName): null,
+              hints,
+              DatasetType.EXTERNAL,
+              edd,
+              withRecord,
+              ifNotExists);
+       } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+       }
       }
 
     | ( <INTERNAL> )?
@@ -498,8 +500,8 @@
     ( <AUTOGENERATED> { autogenerated = true; } )?
     ( <ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
-    ( <WITH> <FILTER> <ON> filterField = NestedField() )?
+    ( LOOKAHEAD(2) <WITH> <FILTER> <ON> filterField = NestedField() )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         if(filterField!=null && filterField.first!=0){
           throw new ParseException("A filter field can only be a field in the main record of the dataset.");
@@ -508,19 +510,22 @@
                                                           primaryKeyFields.first,
                                                           autogenerated,
                                                           filterField == null? null : filterField.second);
-        dsetDecl = new DatasetDecl(nameComponents.first,
+        try{
+          dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    typeComponents.first,
                                    typeComponents.second,
                                    metaTypeComponents.first,
                                    metaTypeComponents.second,
                                    nodeGroupName != null ? new Identifier(nodeGroupName) : null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.INTERNAL,
                                    idd,
+                                   withRecord,
                                    ifNotExists);
+        } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+        }
       }
   )
     {
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
index 1ca8ac4..c0beef4 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
@@ -38,9 +38,9 @@
         LONG
     }
 
-    abstract public Object getValue();
+    public abstract Object getValue();
 
-    abstract public Type getLiteralType();
+    public abstract Type getLiteralType();
 
     public String getStringValue() {
         return getValue().toString();
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
index 2a527d5..e6a5263 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/ListConstructor.java
@@ -19,12 +19,15 @@
 package org.apache.asterix.lang.common.expression;
 
 import java.util.List;
+import java.util.Objects;
 
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.lang.common.base.AbstractExpression;
 import org.apache.asterix.lang.common.base.Expression;
+import org.apache.asterix.lang.common.util.ExpressionUtils;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
+import org.apache.asterix.object.base.AdmArrayNode;
+import org.apache.asterix.object.base.IAdmNode;
 
 public class ListConstructor extends AbstractExpression {
     private List<Expression> exprList;
@@ -72,7 +75,7 @@
 
     @Override
     public int hashCode() {
-        return ObjectUtils.hashCodeMulti(exprList, type);
+        return Objects.hash(exprList, type);
     }
 
     @Override
@@ -84,6 +87,14 @@
             return false;
         }
         ListConstructor target = (ListConstructor) object;
-        return ObjectUtils.equals(exprList, target.exprList) && ObjectUtils.equals(type, target.type);
+        return Objects.equals(exprList, target.exprList) && Objects.equals(type, target.type);
+    }
+
+    public IAdmNode toNode() throws CompilationException {
+        AdmArrayNode array = new AdmArrayNode(exprList.size());
+        for (int i = 0; i < exprList.size(); i++) {
+            array.add(ExpressionUtils.toNode(exprList.get(i)));
+        }
+        return array;
     }
 }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
index 095f098..2e079cc 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/LiteralExpr.java
@@ -18,11 +18,22 @@
  */
 package org.apache.asterix.lang.common.expression;
 
+import java.util.Objects;
+
 import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.lang.common.base.AbstractExpression;
 import org.apache.asterix.lang.common.base.Literal;
+import org.apache.asterix.lang.common.literal.DoubleLiteral;
+import org.apache.asterix.lang.common.literal.LongIntegerLiteral;
+import org.apache.asterix.lang.common.literal.StringLiteral;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
+import org.apache.asterix.object.base.AdmBigIntNode;
+import org.apache.asterix.object.base.AdmBooleanNode;
+import org.apache.asterix.object.base.AdmDoubleNode;
+import org.apache.asterix.object.base.AdmNullNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
 
 public class LiteralExpr extends AbstractExpression {
     private Literal value;
@@ -55,7 +66,7 @@
 
     @Override
     public int hashCode() {
-        return ObjectUtils.hashCode(value);
+        return Objects.hashCode(value);
     }
 
     @Override
@@ -67,6 +78,25 @@
             return false;
         }
         LiteralExpr target = (LiteralExpr) object;
-        return ObjectUtils.equals(value, target.value);
+        return Objects.equals(value, target.value);
+    }
+
+    public IAdmNode toNode() throws CompilationException {
+        switch (value.getLiteralType()) {
+            case DOUBLE:
+                return new AdmDoubleNode(((DoubleLiteral) value).getDoubleValue());
+            case FALSE:
+            case TRUE:
+                return AdmBooleanNode.get((Boolean) value.getValue());
+            case LONG:
+                return new AdmBigIntNode(((LongIntegerLiteral) value).getLongValue());
+            case NULL:
+                return AdmNullNode.INSTANCE;
+            case STRING:
+                return new AdmStringNode(((StringLiteral) value).getValue());
+            default:
+                throw new CompilationException(ErrorCode.LITERAL_TYPE_NOT_SUPPORTED_IN_CONSTANT_RECORD,
+                        value.getLiteralType());
+        }
     }
 }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
index 1aa8ff1..49f3760 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/expression/RecordConstructor.java
@@ -19,11 +19,15 @@
 package org.apache.asterix.lang.common.expression;
 
 import java.util.List;
+import java.util.Objects;
 
 import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.lang.common.base.AbstractExpression;
+import org.apache.asterix.lang.common.util.ExpressionUtils;
+import org.apache.asterix.lang.common.util.LangRecordParseUtil;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.IAdmNode;
 
 public class RecordConstructor extends AbstractExpression {
     private List<FieldBinding> fbList;
@@ -57,7 +61,7 @@
 
     @Override
     public int hashCode() {
-        return ObjectUtils.hashCode(fbList);
+        return Objects.hashCode(fbList);
     }
 
     @Override
@@ -69,6 +73,17 @@
             return false;
         }
         RecordConstructor target = (RecordConstructor) object;
-        return ObjectUtils.equals(fbList, target.fbList);
+        return Objects.equals(fbList, target.fbList);
+    }
+
+    public AdmObjectNode toNode() throws CompilationException {
+        AdmObjectNode node = new AdmObjectNode();
+        for (int i = 0; i < fbList.size(); i++) {
+            FieldBinding binding = fbList.get(i);
+            String key = LangRecordParseUtil.exprToStringLiteral(binding.getLeftExpr()).getStringValue();
+            IAdmNode value = ExpressionUtils.toNode(binding.getRightExpr());
+            node.set(key, value);
+        }
+        return node;
     }
 }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
index f362c15..5812b19 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/DoubleLiteral.java
@@ -23,9 +23,9 @@
 
 public class DoubleLiteral extends Literal {
     private static final long serialVersionUID = -5685491458356989250L;
-    private Double value;
+    private double value;
 
-    public DoubleLiteral(Double value) {
+    public DoubleLiteral(double value) {
         super();
         this.value = value;
     }
@@ -35,6 +35,10 @@
         return value;
     }
 
+    public double getDoubleValue() {
+        return value;
+    }
+
     public void setValue(Double value) {
         this.value = value;
     }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
index 66164d1..5e00cb8 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/LongIntegerLiteral.java
@@ -35,6 +35,10 @@
         return value;
     }
 
+    public long getLongValue() {
+        return value;
+    }
+
     public void setValue(Long value) {
         this.value = value;
     }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
index 79d1774..788b8e4 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/statement/DatasetDecl.java
@@ -22,30 +22,35 @@
 
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.expression.RecordConstructor;
 import org.apache.asterix.lang.common.struct.Identifier;
 import org.apache.asterix.lang.common.visitor.base.ILangVisitor;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.runtime.utils.MergePolicyUtils;
 
 public class DatasetDecl implements Statement {
     protected final Identifier name;
     protected final Identifier dataverse;
     protected final Identifier itemTypeDataverse;
     protected final Identifier itemTypeName;
+    protected final Identifier metaItemTypeDataverse;
+    protected final Identifier metaItemTypeName;
     protected final Identifier nodegroupName;
-    protected final String compactionPolicy;
-    protected final Map<String, String> compactionPolicyProperties;
     protected final DatasetType datasetType;
     protected final IDatasetDetailsDecl datasetDetailsDecl;
     protected final Map<String, String> hints;
+    private final AdmObjectNode withRecord;
     protected final boolean ifNotExists;
-
-    protected final Identifier metaItemTypeDataverse;
-    protected final Identifier metaItemTypeName;
 
     public DatasetDecl(Identifier dataverse, Identifier name, Identifier itemTypeDataverse, Identifier itemTypeName,
             Identifier metaItemTypeDataverse, Identifier metaItemTypeName, Identifier nodeGroupName,
-            String compactionPolicy, Map<String, String> compactionPolicyProperties, Map<String, String> hints,
-            DatasetType datasetType, IDatasetDetailsDecl idd, boolean ifNotExists) {
+            Map<String, String> hints, DatasetType datasetType, IDatasetDetailsDecl idd, RecordConstructor withRecord,
+            boolean ifNotExists) throws CompilationException {
         this.dataverse = dataverse;
         this.name = name;
         this.itemTypeName = itemTypeName;
@@ -61,9 +66,8 @@
             this.metaItemTypeDataverse = metaItemTypeDataverse;
         }
         this.nodegroupName = nodeGroupName;
-        this.compactionPolicy = compactionPolicy;
-        this.compactionPolicyProperties = compactionPolicyProperties;
         this.hints = hints;
+        this.withRecord = withRecord == null ? null : withRecord.toNode();
         this.ifNotExists = ifNotExists;
         this.datasetType = datasetType;
         this.datasetDetailsDecl = idd;
@@ -121,12 +125,56 @@
         return nodegroupName;
     }
 
-    public String getCompactionPolicy() {
-        return compactionPolicy;
+    public String getCompactionPolicy() throws CompilationException {
+        AdmObjectNode mergePolicy = getMergePolicyObject();
+        if (mergePolicy == null) {
+            return null;
+        }
+        IAdmNode mergePolicyName = mergePolicy.get(MergePolicyUtils.MERGE_POLICY_NAME_PARAMETER_NAME);
+        if (mergePolicyName == null) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_CONTAIN_SUB_FIELD,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME, MergePolicyUtils.MERGE_POLICY_NAME_PARAMETER_NAME);
+        }
+        if (mergePolicyName.getType() != ATypeTag.STRING) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_BE_OF_TYPE,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME + '.'
+                            + MergePolicyUtils.MERGE_POLICY_NAME_PARAMETER_NAME,
+                    ATypeTag.STRING);
+        }
+        return ((AdmStringNode) mergePolicyName).get();
     }
 
-    public Map<String, String> getCompactionPolicyProperties() {
-        return compactionPolicyProperties;
+    private AdmObjectNode getMergePolicyObject() throws CompilationException {
+        if (withRecord == null) {
+            return null;
+        }
+        IAdmNode mergePolicy = withRecord.get(MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME);
+        if (mergePolicy == null) {
+            return null;
+        }
+        if (!mergePolicy.isObject()) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_BE_OF_TYPE,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME, ATypeTag.OBJECT);
+        }
+        return (AdmObjectNode) mergePolicy;
+    }
+
+    public Map<String, String> getCompactionPolicyProperties() throws CompilationException {
+        AdmObjectNode mergePolicy = getMergePolicyObject();
+        if (mergePolicy == null) {
+            return null;
+        }
+        IAdmNode mergePolicyParameters = mergePolicy.get(MergePolicyUtils.MERGE_POLICY_PARAMETERS_PARAMETER_NAME);
+        if (mergePolicyParameters == null) {
+            return null;
+        }
+        if (mergePolicyParameters.getType() != ATypeTag.OBJECT) {
+            throw new CompilationException(ErrorCode.WITH_FIELD_MUST_BE_OF_TYPE,
+                    MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME + '.'
+                            + MergePolicyUtils.MERGE_POLICY_PARAMETERS_PARAMETER_NAME,
+                    ATypeTag.OBJECT);
+        }
+        return MergePolicyUtils.toProperties((AdmObjectNode) mergePolicyParameters);
     }
 
     public Map<String, String> getHints() {
@@ -156,4 +204,8 @@
         return Category.DDL;
     }
 
+    public AdmObjectNode getWithRecord() {
+        return withRecord;
+    }
+
 }
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
new file mode 100644
index 0000000..aa1ae53
--- /dev/null
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
@@ -0,0 +1,46 @@
+/*
+ * 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.lang.common.util;
+
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.lang.common.base.Expression;
+import org.apache.asterix.lang.common.expression.ListConstructor;
+import org.apache.asterix.lang.common.expression.LiteralExpr;
+import org.apache.asterix.lang.common.expression.RecordConstructor;
+import org.apache.asterix.object.base.IAdmNode;
+
+public class ExpressionUtils {
+    private ExpressionUtils() {
+    }
+
+    public static IAdmNode toNode(Expression expr) throws CompilationException {
+        switch (expr.getKind()) {
+            case LIST_CONSTRUCTOR_EXPRESSION:
+                return ((ListConstructor) expr).toNode();
+            case LITERAL_EXPRESSION:
+                return ((LiteralExpr) expr).toNode();
+            case RECORD_CONSTRUCTOR_EXPRESSION:
+                return ((RecordConstructor) expr).toNode();
+            default:
+                throw new CompilationException(ErrorCode.EXPRESSION_NOT_SUPPORTED_IN_CONSTANT_RECORD, expr.getKind());
+        }
+    }
+
+}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
index 080e2c4..c4b23ef 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/LangRecordParseUtil.java
@@ -26,6 +26,7 @@
 
 import org.apache.asterix.builders.OrderedListBuilder;
 import org.apache.asterix.builders.RecordBuilder;
+import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
 import org.apache.asterix.lang.common.base.Expression;
@@ -56,22 +57,22 @@
 public class LangRecordParseUtil {
     private static final String NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE =
             "JSON record can only have expressions [%1$s, %2$s, %3$s]";
-    private static final ISerializerDeserializer<ADouble> doubleSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ADOUBLE);
-    private static final ISerializerDeserializer<AString> stringSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ASTRING);
-    private static final ISerializerDeserializer<AInt64> intSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.AINT64);
-    private static final ISerializerDeserializer<ABoolean> booleanSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ABOOLEAN);
-    private static final ISerializerDeserializer<ANull> nullSerde = SerializerDeserializerProvider.INSTANCE
-            .getSerializerDeserializer(BuiltinType.ANULL);
+    private static final ISerializerDeserializer<ADouble> doubleSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADOUBLE);
+    private static final ISerializerDeserializer<AString> stringSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
+    private static final ISerializerDeserializer<AInt64> intSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
+    private static final ISerializerDeserializer<ABoolean> booleanSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN);
+    private static final ISerializerDeserializer<ANull> nullSerde =
+            SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ANULL);
 
     private LangRecordParseUtil() {
     }
 
     private static void parseExpression(Expression expr, ArrayBackedValueStorage serialized)
-            throws HyracksDataException {
+            throws HyracksDataException, CompilationException {
         switch (expr.getKind()) {
             case LITERAL_EXPRESSION:
                 parseLiteral((LiteralExpr) expr, serialized);
@@ -84,14 +85,15 @@
                 break;
             default:
                 throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                        NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE, new Serializable[] { Expression.Kind.LITERAL_EXPRESSION
-                                .toString(), Expression.Kind.RECORD_CONSTRUCTOR_EXPRESSION.toString(),
+                        NOT_ALLOWED_EXPRESSIONS_ERROR_MESSAGE,
+                        new Serializable[] { Expression.Kind.LITERAL_EXPRESSION.toString(),
+                                Expression.Kind.RECORD_CONSTRUCTOR_EXPRESSION.toString(),
                                 Expression.Kind.LIST_CONSTRUCTOR_EXPRESSION.toString() });
         }
     }
 
     public static void parseRecord(RecordConstructor recordValue, ArrayBackedValueStorage serialized, boolean tagged,
-            List<Pair<String, String>> defaults) throws HyracksDataException {
+            List<Pair<String, String>> defaults) throws HyracksDataException, CompilationException {
         AMutableString fieldNameString = new AMutableString(null);
         ArrayBackedValueStorage fieldName = new ArrayBackedValueStorage();
         ArrayBackedValueStorage fieldValue = new ArrayBackedValueStorage();
@@ -106,8 +108,8 @@
             // get key
             fieldNameString.setValue(exprToStringLiteral(fb.getLeftExpr()).getStringValue());
             if (!fieldNames.add(fieldNameString.getStringValue())) {
-                throw new HyracksDataException("Field " + fieldNameString.getStringValue()
-                        + " was specified multiple times");
+                throw new HyracksDataException(
+                        "Field " + fieldNameString.getStringValue() + " was specified multiple times");
             }
             stringSerde.serialize(fieldNameString, fieldName.getDataOutput());
             // get value
@@ -127,25 +129,25 @@
         recordBuilder.write(serialized.getDataOutput(), tagged);
     }
 
-    public static Literal exprToStringLiteral(Expression expr) throws HyracksDataException {
+    public static Literal exprToStringLiteral(Expression expr) throws CompilationException {
         if (expr.getKind() != Expression.Kind.LITERAL_EXPRESSION) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                    "Expected expression can only be of type %1$s", Expression.Kind.LITERAL_EXPRESSION);
+            throw new CompilationException(ErrorCode.PARSE_ERROR, "Expected expression can only be of type %1$s",
+                    Expression.Kind.LITERAL_EXPRESSION);
         }
         LiteralExpr keyLiteralExpr = (LiteralExpr) expr;
         Literal keyLiteral = keyLiteralExpr.getValue();
         if (keyLiteral.getLiteralType() != Literal.Type.STRING) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                    "Expected Literal can only be of type %1$s", Literal.Type.STRING);
+            throw new CompilationException(ErrorCode.PARSE_ERROR, "Expected Literal can only be of type %1$s",
+                    Literal.Type.STRING);
         }
         return keyLiteral;
     }
 
     private static void parseList(ListConstructor valueExpr, ArrayBackedValueStorage serialized)
-            throws HyracksDataException {
+            throws CompilationException, HyracksDataException {
         if (valueExpr.getType() != ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR) {
-            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                    "JSON List can't be of type %1$s", valueExpr.getType());
+            throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "JSON List can't be of type %1$s",
+                    valueExpr.getType());
         }
         ArrayBackedValueStorage serializedValue = new ArrayBackedValueStorage();
         OrderedListBuilder listBuilder = new OrderedListBuilder();
@@ -187,13 +189,12 @@
                 stringSerde.serialize(new AString((String) value.getValue()), serialized.getDataOutput());
                 break;
             default:
-                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR,
-                        "Unknown Literal Type %1$s", value.getLiteralType());
+                throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "Unknown Literal Type %1$s",
+                        value.getLiteralType());
         }
     }
 
-    public static void recordToMap(Map<String, String> map, ARecord record)
-            throws AlgebricksException {
+    public static void recordToMap(Map<String, String> map, ARecord record) throws AlgebricksException {
         String[] keys = record.getType().getFieldNames();
         for (int i = 0; i < keys.length; i++) {
             String key = keys[i];
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
index 21a4b76..088e4b3 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
@@ -109,8 +109,8 @@
     private final static String FEED = " feed ";
     private final static String DEFAULT_DATAVERSE_FORMAT = "org.apache.asterix.runtime.formats.NonTaggedDataFormat";
     protected final PrintWriter out;
-    protected Set<Character> validIdentifierChars = new HashSet<Character>();
-    protected Set<Character> validIdentifierStartChars = new HashSet<Character>();
+    protected Set<Character> validIdentifierChars = new HashSet<>();
+    protected Set<Character> validIdentifierStartChars = new HashSet<>();
     protected String dataverseSymbol = " dataverse ";
     protected String datasetSymbol = " dataset ";
     protected String assignSymbol = ":=";
@@ -361,7 +361,7 @@
     @Override
     public Void visit(FunctionDecl fd, Integer step) throws CompilationException {
         out.print(skip(step) + "declare function " + generateFullName(null, fd.getSignature().getName()) + "(");
-        List<Identifier> parameters = new ArrayList<Identifier>();
+        List<Identifier> parameters = new ArrayList<>();
         parameters.addAll(fd.getParamList());
         printDelimitedIdentifiers(parameters, COMMA);
         out.println(") {");
@@ -492,13 +492,6 @@
             out.print(" hints ");
             printProperties(hints);
         }
-        if (dd.getCompactionPolicy() != null) {
-            out.print(" using compaction policy " + revertStringToQuoted(dd.getCompactionPolicy()));
-            Map<String, String> compactionPolicyProperties = dd.getCompactionPolicyProperties();
-            if (compactionPolicyProperties != null && compactionPolicyProperties.size() > 0) {
-                printConfiguration(compactionPolicyProperties);
-            }
-        }
         if (dd.getDatasetType() == DatasetType.INTERNAL) {
             List<String> filterField = ((InternalDetailsDecl) dd.getDatasetDetailsDecl()).getFilterField();
             if (filterField != null && filterField.size() > 0) {
@@ -506,6 +499,10 @@
                 printNestField(filterField);
             }
         }
+        if (dd.getWithRecord() != null) {
+            out.print(" with ");
+            out.print(dd.getWithRecord().toString());
+        }
         out.println(SEMICOLON);
         out.println();
         return null;
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 7ac8c57..c5d6d26 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -493,16 +493,15 @@
   Pair<Identifier,Identifier> typeComponents = null;
   String adapterName = null;
   Map<String,String> properties = null;
-  Map<String,String> compactionPolicyProperties = null;
   FunctionSignature appliedFunction = null;
   Pair<List<Integer>, List<List<String>>> primaryKeyFields = null;
   String nodeGroupName = null;
   Map<String,String> hints = new HashMap<String,String>();
   DatasetDecl dsetDecl = null;
   boolean autogenerated = false;
-  String compactionPolicy = null;
   Pair<Integer, List<String>> filterField = null;
   Pair<Identifier,Identifier> metaTypeComponents = new Pair<Identifier, Identifier>(null, null);
+  RecordConstructor withRecord = null;
 }
 {
   (
@@ -510,13 +509,14 @@
     <LEFTPAREN> typeComponents = TypeName() <RIGHTPAREN>
     ifNotExists = IfNotExists()
     <USING> adapterName = AdapterName() properties = Configuration()
-    (<ON> nodeGroupName = Identifier() )?
+    ( <ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (LOOKAHEAD(1) compactionPolicyProperties = Configuration())? )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         ExternalDetailsDecl edd = new ExternalDetailsDecl();
         edd.setAdapter(adapterName);
         edd.setProperties(properties);
+        try{
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    typeComponents.first,
@@ -524,12 +524,14 @@
                                    metaTypeComponents.first,
                                    metaTypeComponents.second,
                                    nodeGroupName != null? new Identifier(nodeGroupName): null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.EXTERNAL,
                                    edd,
+                                   withRecord,
                                    ifNotExists);
+        } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+        }
       }
 
     | ( <INTERNAL> )?
@@ -551,8 +553,8 @@
     (<AUTOGENERATED> { autogenerated = true; } )?
     (<ON> nodeGroupName = Identifier() )?
     ( <HINTS> hints = Properties() )?
-    ( <USING> <COMPACTION> <POLICY> compactionPolicy = CompactionPolicy() (LOOKAHEAD(1) compactionPolicyProperties = Configuration())? )?
     ( LOOKAHEAD(2) <WITH> <FILTER> <ON>  filterField = NestedField() )?
+    ( <WITH> withRecord = RecordConstructor() )?
       {
         if(filterField!=null && filterField.first!=0){
           throw new ParseException("A filter field can only be a field in the main record of the dataset.");
@@ -561,6 +563,7 @@
                                                           primaryKeyFields.first,
                                                           autogenerated,
                                                           filterField == null? null : filterField.second);
+        try{
         dsetDecl = new DatasetDecl(nameComponents.first,
                                    nameComponents.second,
                                    typeComponents.first,
@@ -568,12 +571,14 @@
                                    metaTypeComponents.first,
                                    metaTypeComponents.second,
                                    nodeGroupName != null ? new Identifier(nodeGroupName) : null,
-                                   compactionPolicy,
-                                   compactionPolicyProperties,
                                    hints,
                                    DatasetType.INTERNAL,
                                    idd,
+                                   withRecord,
                                    ifNotExists);
+        } catch (CompilationException e){
+           throw new ParseException(e.getMessage());
+        }
       }
   )
     {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
new file mode 100644
index 0000000..e489cd5
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmArrayNode.java
@@ -0,0 +1,77 @@
+/*
+ * 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.object.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmArrayNode implements IAdmNode {
+    private final List<IAdmNode> children;
+
+    public AdmArrayNode() {
+        children = new ArrayList<>();
+    }
+
+    public AdmArrayNode(int initialCapacity) {
+        children = new ArrayList<>(initialCapacity);
+    }
+
+    public IAdmNode set(int index, boolean value) {
+        return set(index, AdmBooleanNode.get(value));
+    }
+
+    public void add(boolean value) {
+        add(AdmBooleanNode.get(value));
+    }
+
+    public void add(IAdmNode value) {
+        if (value == null) {
+            value = AdmNullNode.INSTANCE; // NOSONAR
+        }
+        children.add(value);
+    }
+
+    public IAdmNode set(int index, IAdmNode value) {
+        if (value == null) {
+            value = AdmNullNode.INSTANCE; // NOSONAR
+        }
+        return children.set(index, value);
+    }
+
+    public IAdmNode get(int index) {
+        return children.get(index);
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.ARRAY;
+    }
+
+    @Override
+    public void reset() {
+        children.clear();
+    }
+
+    @Override
+    public String toString() {
+        return children.toString();
+    }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
new file mode 100644
index 0000000..0006668
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBigIntNode.java
@@ -0,0 +1,55 @@
+/*
+ * 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.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmBigIntNode implements IAdmNode {
+    private long value;
+
+    public AdmBigIntNode() {
+    }
+
+    public AdmBigIntNode(long value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.BIGINT;
+    }
+
+    public void set(long value) {
+        this.value = value;
+    }
+
+    public long get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        value = 0;
+    }
+
+    @Override
+    public String toString() {
+        return Long.toString(value);
+    }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
new file mode 100644
index 0000000..aeebd86
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmBooleanNode.java
@@ -0,0 +1,59 @@
+/*
+ * 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.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmBooleanNode implements IAdmNode {
+
+    public static final AdmBooleanNode TRUE = new AdmBooleanNode(true);
+    public static final AdmBooleanNode FALSE = new AdmBooleanNode(false);
+    private final boolean value;
+
+    private AdmBooleanNode(boolean value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.BOOLEAN;
+    }
+
+    public boolean get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        // Nothing to do
+    }
+
+    public static AdmBooleanNode get(boolean value) {
+        return value ? TRUE : FALSE;
+    }
+
+    public static AdmBooleanNode get(Boolean value) {
+        return value.booleanValue() ? TRUE : FALSE;
+    }
+
+    @Override
+    public String toString() {
+        return Boolean.toString(value);
+    }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
new file mode 100644
index 0000000..0150b4e
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmDoubleNode.java
@@ -0,0 +1,56 @@
+/*
+ * 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.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmDoubleNode implements IAdmNode {
+    private double value;
+
+    public AdmDoubleNode() {
+
+    }
+
+    public AdmDoubleNode(double value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.DOUBLE;
+    }
+
+    public void set(double value) {
+        this.value = value;
+    }
+
+    public double get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        value = 0;
+    }
+
+    @Override
+    public String toString() {
+        return Double.toString(value);
+    }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
new file mode 100644
index 0000000..2804ca3
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmNullNode.java
@@ -0,0 +1,44 @@
+/*
+ * 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.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmNullNode implements IAdmNode {
+
+    public static final AdmNullNode INSTANCE = new AdmNullNode();
+
+    private AdmNullNode() {
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.NULL;
+    }
+
+    @Override
+    public void reset() {
+        // Nothing to reset
+    }
+
+    @Override
+    public String toString() {
+        return "null";
+    }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
new file mode 100644
index 0000000..2f3ffe9
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
@@ -0,0 +1,99 @@
+/*
+ * 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.object.base;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+/**
+ * An adm object instance
+ */
+public class AdmObjectNode implements IAdmNode {
+    private final Map<String, IAdmNode> children;
+
+    public AdmObjectNode() {
+        children = new HashMap<>();
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.OBJECT;
+    }
+
+    public int size() {
+        return children.size();
+    }
+
+    public IAdmNode get(String fieldName) {
+        return children.get(fieldName);
+    }
+
+    public Set<String> getFieldNames() {
+        return children.keySet();
+    }
+
+    public Set<Entry<String, IAdmNode>> getFields() {
+        return children.entrySet();
+    }
+
+    public AdmObjectNode set(String fieldName, IAdmNode value) {
+        if (value == null) {
+            value = AdmNullNode.INSTANCE; // NOSONAR
+        }
+        children.put(fieldName, value);
+        return this;
+    }
+
+    public AdmObjectNode set(String fieldName, boolean value) {
+        return set(fieldName, AdmBooleanNode.get(value));
+    }
+
+    public IAdmNode remove(String fieldName) {
+        return children.remove(fieldName);
+    }
+
+    @Override
+    public void reset() {
+        children.clear();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("{");
+        int count = 0;
+        for (Map.Entry<String, IAdmNode> en : children.entrySet()) {
+            if (count > 0) {
+                sb.append(",");
+            }
+            ++count;
+            sb.append('"');
+            sb.append(en.getKey());
+            sb.append('"');
+            sb.append(':');
+            sb.append(en.getValue().toString());
+        }
+        sb.append("}");
+        return sb.toString();
+    }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
new file mode 100644
index 0000000..4c92f09
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmStringNode.java
@@ -0,0 +1,52 @@
+/*
+ * 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.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+public class AdmStringNode implements IAdmNode {
+    private String value;
+
+    public AdmStringNode() {
+    }
+
+    public AdmStringNode(String value) {
+        this.value = value;
+    }
+
+    @Override
+    public ATypeTag getType() {
+        return ATypeTag.STRING;
+    }
+
+    public String get() {
+        return value;
+    }
+
+    @Override
+    public void reset() {
+        value = null;
+    }
+
+    @Override
+    public String toString() {
+        return "\"" + value + "\"";
+    }
+
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
new file mode 100644
index 0000000..c382fd2
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/IAdmNode.java
@@ -0,0 +1,65 @@
+/*
+ * 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.object.base;
+
+import org.apache.asterix.om.types.ATypeTag;
+
+/**
+ * An interface representing an adm node
+ */
+public interface IAdmNode {
+
+    /**
+     * @return true if the object is a value, false if the object is a container
+     */
+    default boolean isValueNode() {
+        switch (getType()) {
+            case ARRAY:
+            case OBJECT:
+            case MULTISET:
+                return false;
+            default:
+                return true;
+        }
+    }
+
+    /**
+     * @return true if the object is an array, false otherwise
+     */
+    default boolean isArray() {
+        return getType() == ATypeTag.ARRAY;
+    }
+
+    /**
+     * @return true if the object is an adm object, false otherwise
+     */
+    default boolean isObject() {
+        return getType() == ATypeTag.OBJECT;
+    }
+
+    /**
+     * @return the type tag of the object
+     */
+    ATypeTag getType();
+
+    /**
+     * reset the node
+     */
+    void reset();
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/MergePolicyUtils.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/MergePolicyUtils.java
new file mode 100644
index 0000000..3c1e8a5
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/MergePolicyUtils.java
@@ -0,0 +1,67 @@
+/*
+ * 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.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.object.base.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
+
+public class MergePolicyUtils {
+    public static final String MERGE_POLICY_PARAMETER_NAME = "merge policy";
+    public static final String MERGE_POLICY_NAME_PARAMETER_NAME = "name";
+    public static final String MERGE_POLICY_PARAMETERS_PARAMETER_NAME = "parameters";
+
+    private MergePolicyUtils() {
+    }
+
+    /**
+     * Convert the parameters object to a Map<String,String>
+     * This method should go away once we store the with object as it is in storage
+     *
+     * @param parameters
+     *            the parameters passed for the merge policy in the with clause
+     * @return the parameters as a map
+     */
+    public static Map<String, String> toProperties(AdmObjectNode parameters) throws CompilationException {
+        Map<String, String> map = new HashMap<>();
+        for (Entry<String, IAdmNode> field : parameters.getFields()) {
+            IAdmNode value = field.getValue();
+            switch (value.getType()) {
+                case BOOLEAN:
+                case DOUBLE:
+                case BIGINT:
+                    map.put(field.getKey(), value.toString());
+                    break;
+                case STRING:
+                    map.put(field.getKey(), ((AdmStringNode) value).get());
+                    break;
+                default:
+                    throw new CompilationException(ErrorCode.MERGE_POLICY_PARAMETER_INVALID_TYPE, value.getType());
+            }
+        }
+        return map;
+    }
+
+}

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2183
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I040f4c74cfa0170b8888128ad5f975e196658776
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <bamousaa@gmail.com>


Mime
View raw message