[ASTERIXDB-2182][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> {
"merge-policy": {
"name": "prefix",
"parameters": { "number": 123, "size": 456 }
}
};
- compaction and policy are not key words anymore
Change-Id: I040f4c74cfa0170b8888128ad5f975e196658776
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2183
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
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..6976507 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
@@ -36,6 +36,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@@ -85,7 +86,11 @@
import org.apache.asterix.lang.common.base.IRewriterFactory;
import org.apache.asterix.lang.common.base.IStatementRewriter;
import org.apache.asterix.lang.common.base.Statement;
+import org.apache.asterix.lang.common.expression.FieldBinding;
import org.apache.asterix.lang.common.expression.IndexedTypeExpression;
+import org.apache.asterix.lang.common.expression.LiteralExpr;
+import org.apache.asterix.lang.common.expression.RecordConstructor;
+import org.apache.asterix.lang.common.literal.StringLiteral;
import org.apache.asterix.lang.common.statement.CompactStatement;
import org.apache.asterix.lang.common.statement.ConnectFeedStatement;
import org.apache.asterix.lang.common.statement.CreateDataverseStatement;
@@ -155,6 +160,7 @@
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.TypeSignature;
+import org.apache.asterix.lang.common.util.MergePolicyUtils;
import org.apache.asterix.transaction.management.service.transaction.DatasetIdFactory;
import org.apache.asterix.translator.AbstractLangTranslator;
import org.apache.asterix.translator.CompiledStatements.CompiledDeleteStatement;
@@ -2873,13 +2879,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 +2896,43 @@
FlushDatasetUtil.flushDataset(hcc, metadataProvider, dataverseNameFrom, datasetNameFrom);
}
+ private static RecordConstructor getWithRecord(Dataset dataset) {
+ String mergePolicy = dataset.getCompactionPolicy();
+ Map<String, String> mergePolicyProperties = dataset.getCompactionPolicyProperties();
+ if (mergePolicy.equals(GlobalConfig.DEFAULT_COMPACTION_POLICY_NAME)
+ && mergePolicyProperties.equals(GlobalConfig.DEFAULT_COMPACTION_POLICY_PROPERTIES)) {
+ return null;
+ }
+ List<FieldBinding> mergePolicyRecordFields = new ArrayList<>(mergePolicyProperties == null ? 1 : 2);
+ mergePolicyRecordFields.add(toFieldBinding(MergePolicyUtils.MERGE_POLICY_NAME_PARAMETER_NAME, mergePolicy));
+ if (mergePolicyProperties != null) {
+ mergePolicyRecordFields.add(
+ toFieldBinding(MergePolicyUtils.MERGE_POLICY_PARAMETERS_PARAMETER_NAME, mergePolicyProperties));
+ }
+ FieldBinding mergePolicyBinding = toFieldBinding(MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME,
+ new RecordConstructor(mergePolicyRecordFields));
+ List<FieldBinding> withRecordFields = new ArrayList<>(1);
+ withRecordFields.add(mergePolicyBinding);
+ return new RecordConstructor(withRecordFields);
+ }
+
+ private static FieldBinding toFieldBinding(String key, Map<String, String> value) {
+ List<FieldBinding> fields = new ArrayList<>(value.size());
+ for (Entry<String, String> entry : value.entrySet()) {
+ fields.add(toFieldBinding(entry.getKey(), entry.getValue()));
+ }
+ RecordConstructor record = new RecordConstructor(fields);
+ return toFieldBinding(key, record);
+ }
+
+ private static FieldBinding toFieldBinding(String key, RecordConstructor value) {
+ return new FieldBinding(new LiteralExpr(new StringLiteral(key)), value);
+ }
+
+ private static FieldBinding toFieldBinding(String key, String value) {
+ return new FieldBinding(new LiteralExpr(new StringLiteral(key)), new LiteralExpr(new StringLiteral(value)));
+ }
+
// 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..ad5121d 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..352f821 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 }
+ }
+};
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..4c244c8 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..7fa85b8 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..d60105e 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,10 @@
}
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 }
+ }
+};
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..61e144e 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
@@ -58,4 +63,4 @@
("format"="delimited-text"),
("delimiter"="|"),
("type-name"="LineItemType"),
-("tuple-interval"="10"));
\ No newline at end of file
+("tuple-interval"="10"));
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..bf03e36 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": 16384, "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..8ee9893 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,4 @@
}
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..1f41b10 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..da5aeab 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/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.aql
index 511775d..fc8dd52 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/insert-with-correlated-secondary-btree/insert-with-correlated-secondary-btree.1.ddl.aql
@@ -36,12 +36,20 @@
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/filters/upsert/upsert.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/filters/upsert/upsert.1.ddl.aql
index 4adc491..cb270f9 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..b3c496b 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 }
+ }
+};
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..4a6a5d2 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 }
+ }
+};
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..70ae710 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..fae8310 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 }
+ }
+};
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..f867ad4 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..1d286ca 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..79b4547 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..e22bdc1 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..2f45268 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..7ea63ee 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 3e1b6d5d..8481c6f 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..6569e65 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..82494ee 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..b6e0d1c 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..95d2b8f 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..2c30b4b 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..8f18401 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..9ff7255 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..82b4683 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..ac91578 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..c805844 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..7847d7e 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..f6a3ce6 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..336d475 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..aa4efdb 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,11 @@
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..1c22a9d 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..66aaf10 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..ae60be0 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..0e1ece1 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..0b9d178 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..63db3be 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..574d5a5 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..e176108 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..3bf80d4 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..589e7f9 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..b42d017 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..edfa1d3 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..6095171 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..0b2b260 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..4cc2324 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 }
+ }
+};
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..1c85ff9 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,12 @@
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 UNSUPPORTED_WITH_FIELD = 1059;
+ public static final int WITH_FIELD_MUST_BE_OF_TYPE = 1060;
+ public static final int WITH_FIELD_MUST_CONTAIN_SUB_FIELD = 1061;
+ public static final int MERGE_POLICY_PARAMETER_INVALID_TYPE = 1062;
// 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..61d8291 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,12 @@
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\" unsupported in the with clause
+1060 = Field \"%1$s\" in the with clause must be of type %2$s
+1061 = Field \"%1$s\" in the with clause must contain sub field \"%2$s\"
+1062 = Merge policy parameters cannot be of type %1$s
# Feed Errors
3001 = Illegal state.
diff --git a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql
index be29328..bdce483 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_ngram_index/primary_plus_correlated_ngram_index.2.ddl.aql
@@ -61,12 +61,20 @@
/* Create dataset for loading raw Fragile data */
create dataset Fragile_raw (FragileTypeRaw)
primary key row_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 for cleaned Fragile data */
create dataset Fragile (FragileType)
primary key row_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-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql
index 9443205..0fa78f2 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_correlated_rtree_index/primary_plus_correlated_rtree_index.2.ddl.aql
@@ -62,11 +62,20 @@
/* Create dataset for loading raw Fragile data */
create dataset Fragile_raw (FragileTypeRaw)
primary key row_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 for cleaned Fragile data */
create dataset Fragile (FragileType)
primary key row_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-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql
index 618c6b1..b27ec90 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_default_correlated_secondary_index/primary_plus_default_correlated_secondary_index.2.ddl.aql
@@ -60,12 +60,20 @@
/* Create dataset for loading raw Fragile data */
create dataset Fragile_raw (FragileTypeRaw)
primary key row_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 for cleaned Fragile data */
create dataset Fragile (FragileType)
primary key row_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-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql
index b1f61e2..c79a54c 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_keyword_correlated_secondary_index/primary_plus_keyword_correlated_secondary_index.2.ddl.aql
@@ -62,12 +62,20 @@
/* Create dataset for loading raw Fragile data */
create dataset Fragile_raw (FragileTypeRaw)
primary key row_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 for cleaned Fragile data */
create dataset Fragile (FragileType)
primary key row_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-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql
index 69a6c9d..e473591 100644
--- a/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql
+++ b/asterixdb/asterix-installer/src/test/resources/transactionts/queries/recover_after_abort/primary_plus_multiple_correlated_secondary_indices/primary_plus_multiple_correlated_secondary_indices.2.ddl.aql
@@ -62,12 +62,20 @@
/* Create dataset for loading raw Fragile data */
create dataset Fragile_raw (FragileTypeRaw)
primary key row_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 for cleaned Fragile data */
create dataset Fragile (FragileType)
primary key row_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-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 1ca8ac46..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..ca5dd57 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,12 @@
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.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
public class ListConstructor extends AbstractExpression {
private List<Expression> exprList;
@@ -72,7 +72,7 @@
@Override
public int hashCode() {
- return ObjectUtils.hashCodeMulti(exprList, type);
+ return Objects.hash(exprList, type);
}
@Override
@@ -84,6 +84,6 @@
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);
}
}
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..0c3fdb1 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,6 @@
return false;
}
LiteralExpr target = (LiteralExpr) object;
- return ObjectUtils.equals(value, target.value);
+ return Objects.equals(value, target.value);
}
}
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..cce92e6 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,11 @@
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.visitor.base.ILangVisitor;
-import org.apache.commons.lang3.ObjectUtils;
public class RecordConstructor extends AbstractExpression {
private List<FieldBinding> fbList;
@@ -57,7 +57,7 @@
@Override
public int hashCode() {
- return ObjectUtils.hashCode(fbList);
+ return Objects.hashCode(fbList);
}
@Override
@@ -69,6 +69,6 @@
return false;
}
RecordConstructor target = (RecordConstructor) object;
- return ObjectUtils.equals(fbList, target.fbList);
+ return Objects.equals(fbList, target.fbList);
}
}
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..e63dae6 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
@@ -18,34 +18,47 @@
*/
package org.apache.asterix.lang.common.statement;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
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.util.ExpressionUtils;
+import org.apache.asterix.lang.common.util.MergePolicyUtils;
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.hyracks.algebricks.common.exceptions.AlgebricksException;
public class DatasetDecl implements Statement {
+ protected static final String[] WITH_OBJECT_FIELDS = new String[] { MergePolicyUtils.MERGE_POLICY_PARAMETER_NAME };
+ protected static final Set<String> WITH_OBJECT_FIELDS_SET = new HashSet<>(Arrays.asList(WITH_OBJECT_FIELDS));
+
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 withObjectNode;
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 +74,15 @@
this.metaItemTypeDataverse = metaItemTypeDataverse;
}
this.nodegroupName = nodeGroupName;
- this.compactionPolicy = compactionPolicy;
- this.compactionPolicyProperties = compactionPolicyProperties;
this.hints = hints;
+ try {
+ this.withObjectNode = withRecord == null ? null : ExpressionUtils.toNode(withRecord);
+ } catch (CompilationException e) {
+ throw e;
+ } catch (AlgebricksException e) {
+ // TODO(tillw) make signatures throw Algebricks exceptions
+ throw new CompilationException(e);
+ }
this.ifNotExists = ifNotExists;
this.datasetType = datasetType;
this.datasetDetailsDecl = idd;
@@ -121,12 +140,68 @@
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 static AdmObjectNode validateWithObject(AdmObjectNode withObject) throws CompilationException {
+ if (withObject == null) {
+ return null;
+ }
+ for (String name : withObject.getFieldNames()) {
+ if (!WITH_OBJECT_FIELDS_SET.contains(name)) {
+ throw new CompilationException(ErrorCode.UNSUPPORTED_WITH_FIELD, name);
+ }
+ }
+ return withObject;
+ }
+
+ private AdmObjectNode getMergePolicyObject() throws CompilationException {
+ if (withObjectNode == null) {
+ return null;
+ }
+ IAdmNode mergePolicy = validateWithObject(withObjectNode).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 +231,8 @@
return Category.DDL;
}
+ public AdmObjectNode getWithObjectNode() {
+ return withObjectNode;
+ }
+
}
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..25f9d07
--- /dev/null
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
@@ -0,0 +1,101 @@
+/*
+ * 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 java.util.List;
+
+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.base.Literal;
+import org.apache.asterix.lang.common.expression.FieldBinding;
+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.lang.common.literal.DoubleLiteral;
+import org.apache.asterix.lang.common.literal.LongIntegerLiteral;
+import org.apache.asterix.lang.common.literal.StringLiteral;
+import org.apache.asterix.object.base.AdmArrayNode;
+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.AdmObjectNode;
+import org.apache.asterix.object.base.AdmStringNode;
+import org.apache.asterix.object.base.IAdmNode;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+public class ExpressionUtils {
+ private ExpressionUtils() {
+ }
+
+ public static IAdmNode toNode(Expression expr) throws AlgebricksException {
+ switch (expr.getKind()) {
+ case LIST_CONSTRUCTOR_EXPRESSION:
+ return toNode((ListConstructor) expr);
+ case LITERAL_EXPRESSION:
+ return toNode((LiteralExpr) expr);
+ case RECORD_CONSTRUCTOR_EXPRESSION:
+ return toNode((RecordConstructor) expr);
+ default:
+ throw new CompilationException(ErrorCode.EXPRESSION_NOT_SUPPORTED_IN_CONSTANT_RECORD, expr.getKind());
+ }
+ }
+
+ public static AdmObjectNode toNode(RecordConstructor recordConstructor) throws AlgebricksException {
+ AdmObjectNode node = new AdmObjectNode();
+ final List<FieldBinding> fbList = recordConstructor.getFbList();
+ 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;
+ }
+
+ private static IAdmNode toNode(ListConstructor listConstructor) throws AlgebricksException {
+ final List<Expression> exprList = listConstructor.getExprList();
+ AdmArrayNode array = new AdmArrayNode(exprList.size());
+ for (int i = 0; i < exprList.size(); i++) {
+ array.add(ExpressionUtils.toNode(exprList.get(i)));
+ }
+ return array;
+ }
+
+ private static IAdmNode toNode(LiteralExpr literalExpr) throws AlgebricksException {
+ final Literal value = literalExpr.getValue();
+ final Literal.Type literalType = value.getLiteralType();
+ switch (literalType) {
+ 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, literalType);
+ }
+ }
+}
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/util/MergePolicyUtils.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/MergePolicyUtils.java
new file mode 100644
index 0000000..6bb5c36
--- /dev/null
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/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.lang.common.util;
+
+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;
+ }
+
+}
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..ea81865 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.getWithObjectNode() != null) {
+ out.print(" with ");
+ out.print(dd.getWithObjectNode().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..e35b28f
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/object/base/AdmObjectNode.java
@@ -0,0 +1,95 @@
+/*
+ * 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 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();
+}