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

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


The following commit(s) were added to refs/heads/master by this push:
     new f8d2524927 [ASTERIXDB-3324][COMP] Create column dataset validations
f8d2524927 is described below

commit f8d2524927db0184e44d79231aa403d5a77984f9
Author: Wail Alkowaileet <[email protected]>
AuthorDate: Fri Dec 8 09:20:56 2023 -0800

    [ASTERIXDB-3324][COMP] Create column dataset validations
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    When creating a dataset
    - Ensure 'storage-format' is valid
    
    When creating a columnar dataset:
    - Disallow correlated-prefix merge policy
    - Disallow LSM-filters
    
    Secondary indexes:
    - Disallow RTree and inverted indexes
    
    Change-Id: I032e534f6ec716e13ea359334eee3ea227054efe
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18004
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Wail Alkowaileet <[email protected]>
    Reviewed-by: Ali Alsuliman <[email protected]>
---
 .../rules/EnsureColumnarSupportedTypesRule.java    |  2 +-
 .../asterix/app/translator/QueryTranslator.java    |  7 +++-
 .../column/validation/00-merge-policy.00.ddl.sqlpp | 39 +++++++++++++++++
 .../column/validation/01-lsm-filter.01.ddl.sqlpp   | 34 +++++++++++++++
 .../02-unsupported-storage-format.02.ddl.sqlpp     | 32 ++++++++++++++
 .../validation/03-unsupported-index.03.ddl.sqlpp   | 34 +++++++++++++++
 .../validation/03-unsupported-index.04.ddl.sqlpp   | 34 +++++++++++++++
 .../validation/03-unsupported-index.05.ddl.sqlpp   | 34 +++++++++++++++
 .../src/test/resources/runtimets/sqlpp_queries.xml | 12 ++++++
 .../validation/ColumnPropertiesValidationUtil.java | 49 ++++++++++++++++++++++
 .../ColumnSupportedTypesValidator.java             |  2 +-
 .../asterix/common/config/DatasetConfig.java       | 12 +++++-
 .../asterix/common/exceptions/ErrorCode.java       |  4 ++
 .../src/main/resources/asx_errormsg/en.properties  |  4 ++
 .../asterix/lang/common/statement/DatasetDecl.java |  2 +-
 .../utils/SecondaryIndexOperationsHelper.java      | 21 +++++++++-
 16 files changed, 314 insertions(+), 8 deletions(-)

diff --git 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/EnsureColumnarSupportedTypesRule.java
 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/EnsureColumnarSupportedTypesRule.java
index 8840c8fd42..ef5348080c 100644
--- 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/EnsureColumnarSupportedTypesRule.java
+++ 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/EnsureColumnarSupportedTypesRule.java
@@ -18,7 +18,7 @@
  */
 package org.apache.asterix.optimizer.rules;
 
-import 
org.apache.asterix.column.metadata.schema.visitor.ColumnSupportedTypesValidator;
+import org.apache.asterix.column.validation.ColumnSupportedTypesValidator;
 import org.apache.asterix.common.config.DatasetConfig;
 import org.apache.asterix.common.metadata.DataverseName;
 import org.apache.asterix.metadata.declared.DataSource;
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 20da442fd0..8071fd8a14 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
@@ -64,7 +64,8 @@ import org.apache.asterix.app.result.fields.ErrorsPrinter;
 import org.apache.asterix.app.result.fields.ResultHandlePrinter;
 import org.apache.asterix.app.result.fields.ResultsPrinter;
 import org.apache.asterix.app.result.fields.StatusPrinter;
-import 
org.apache.asterix.column.metadata.schema.visitor.ColumnSupportedTypesValidator;
+import org.apache.asterix.column.validation.ColumnPropertiesValidationUtil;
+import org.apache.asterix.column.validation.ColumnSupportedTypesValidator;
 import org.apache.asterix.common.api.IApplicationContext;
 import org.apache.asterix.common.api.IClientRequest;
 import org.apache.asterix.common.api.IMetadataLockManager;
@@ -981,7 +982,9 @@ public class QueryTranslator extends AbstractLangTranslator 
implements IStatemen
                         compactionPolicyProperties = 
StorageConstants.DEFAULT_COMPACTION_POLICY_PROPERTIES;
                     }
                     boolean isDatasetWithoutTypeSpec = 
aRecordType.getFieldNames().length == 0 && metaRecType == null;
-
+                    // Validate dataset properties if the format is COLUMN
+                    ColumnPropertiesValidationUtil.validate(sourceLoc, 
datasetFormatInfo.getFormat(), compactionPolicy,
+                            filterField);
                     datasetDetails = new 
InternalDatasetDetails(InternalDatasetDetails.FileStructure.BTREE,
                             InternalDatasetDetails.PartitioningStrategy.HASH, 
partitioningExprs, partitioningExprs,
                             keySourceIndicators, partitioningTypes, 
autogenerated, filterSourceIndicator, filterField,
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/00-merge-policy.00.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/00-merge-policy.00.ddl.sqlpp
new file mode 100644
index 0000000000..a11941ff3d
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/00-merge-policy.00.ddl.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+DROP DATAVERSE test if exists;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE TYPE ColumnType AS {
+    id: int
+};
+
+CREATE DATASET ColumnDataset(ColumnType)
+PRIMARY KEY id
+WITH {
+    "storage-format": {"format" : "column"},
+    "merge-policy": {
+        "name": "correlated-prefix",
+        "parameters": {
+            "max-mergable-component-size": 16384,
+            "max-tolerance-component-count": 3
+        }
+    }
+};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/01-lsm-filter.01.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/01-lsm-filter.01.ddl.sqlpp
new file mode 100644
index 0000000000..72c9334a48
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/01-lsm-filter.01.ddl.sqlpp
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+DROP DATAVERSE test if exists;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE TYPE ColumnType AS {
+    id: int,
+    my_timestamp: int
+};
+
+CREATE DATASET ColumnDataset(ColumnType)
+PRIMARY KEY id
+WITH FILTER ON my_timestamp
+WITH {
+    "storage-format": {"format" : "column"}
+};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/02-unsupported-storage-format.02.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/02-unsupported-storage-format.02.ddl.sqlpp
new file mode 100644
index 0000000000..7d39cd99d8
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/02-unsupported-storage-format.02.ddl.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+DROP DATAVERSE test if exists;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE TYPE ColumnType AS {
+    id: int
+};
+
+CREATE DATASET ColumnDataset(ColumnType)
+PRIMARY KEY id
+WITH {
+    "storage-format": {"format" : "col"}
+};
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.03.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.03.ddl.sqlpp
new file mode 100644
index 0000000000..83e16fdc4e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.03.ddl.sqlpp
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+DROP DATAVERSE test if exists;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE TYPE ColumnType AS {
+    id: int
+};
+
+CREATE DATASET ColumnDataset(ColumnType)
+PRIMARY KEY id
+WITH {
+    "storage-format": {"format" : "column"}
+};
+
+CREATE INDEX rtree_idx ON ColumnDataset(my_geo: point?) TYPE RTREE ENFORCED;
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.04.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.04.ddl.sqlpp
new file mode 100644
index 0000000000..1cdec5506d
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.04.ddl.sqlpp
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+DROP DATAVERSE test if exists;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE TYPE ColumnType AS {
+    id: int
+};
+
+CREATE DATASET ColumnDataset(ColumnType)
+PRIMARY KEY id
+WITH {
+    "storage-format": {"format" : "column"}
+};
+
+CREATE INDEX ngram_idx ON ColumnDataset(my_text: string?) TYPE NGRAM(3) 
ENFORCED;
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.05.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.05.ddl.sqlpp
new file mode 100644
index 0000000000..86c95c3023
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/validation/03-unsupported-index.05.ddl.sqlpp
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+DROP DATAVERSE test if exists;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE TYPE ColumnType AS {
+    id: int
+};
+
+CREATE DATASET ColumnDataset(ColumnType)
+PRIMARY KEY id
+WITH {
+    "storage-format": {"format" : "column"}
+};
+
+CREATE INDEX ngram_idx ON ColumnDataset(my_text: string?) TYPE KEYWORD 
ENFORCED;
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index 90444fbe5e..c6fe190df9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -16448,6 +16448,18 @@
         <source-location>false</source-location>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="column">
+      <compilation-unit name="validation">
+        <output-dir compare="Text">validation</output-dir>
+        <expected-error>ASX1191: Merge policy 'correlated-prefix' is not 
supported with columnar storage format</expected-error>
+        <expected-error>ASX1192: Filters are not supported with columnar 
storage format</expected-error>
+        <expected-error>ASX1193: Unknown storage format 'col'</expected-error>
+        <expected-error>ASX1194: Index type 'RTREE' is not supported with 
columnar storage format</expected-error>
+        <expected-error>ASX1194: Index type 'LENGTH_PARTITIONED_NGRAM_INVIX' 
is not supported with columnar storage format</expected-error>
+        <expected-error>ASX1194: Index type 'LENGTH_PARTITIONED_WORD_INVIX' is 
not supported with columnar storage format</expected-error>
+        <source-location>false</source-location>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="copy-from">
     <test-case FilePath="copy-from">
diff --git 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/validation/ColumnPropertiesValidationUtil.java
 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/validation/ColumnPropertiesValidationUtil.java
new file mode 100644
index 0000000000..3fe69077b8
--- /dev/null
+++ 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/validation/ColumnPropertiesValidationUtil.java
@@ -0,0 +1,49 @@
+/*
+ * 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.column.validation;
+
+import java.util.List;
+
+import org.apache.asterix.common.config.DatasetConfig;
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.utils.StorageConstants;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+
+public class ColumnPropertiesValidationUtil {
+    private ColumnPropertiesValidationUtil() {
+    }
+
+    public static void validate(SourceLocation sourceLocation, 
DatasetConfig.DatasetFormat format, String mergePolicy,
+            List<String> filterFields) throws AlgebricksException {
+        if (format != DatasetConfig.DatasetFormat.COLUMN) {
+            return;
+        }
+
+        if 
(!StorageConstants.DEFAULT_COMPACTION_POLICY_NAME.equals(mergePolicy)) {
+            throw 
CompilationException.create(ErrorCode.UNSUPPORTED_COLUMN_MERGE_POLICY, 
sourceLocation, mergePolicy);
+        }
+
+        if (filterFields != null && !filterFields.isEmpty()) {
+            throw 
CompilationException.create(ErrorCode.UNSUPPORTED_COLUMN_LSM_FILTER, 
sourceLocation);
+        }
+    }
+
+}
diff --git 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/ColumnSupportedTypesValidator.java
 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/validation/ColumnSupportedTypesValidator.java
similarity index 98%
rename from 
asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/ColumnSupportedTypesValidator.java
rename to 
asterixdb/asterix-column/src/main/java/org/apache/asterix/column/validation/ColumnSupportedTypesValidator.java
index 76ea58fe7f..90a58d4d09 100644
--- 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/ColumnSupportedTypesValidator.java
+++ 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/validation/ColumnSupportedTypesValidator.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.asterix.column.metadata.schema.visitor;
+package org.apache.asterix.column.validation;
 
 import static 
org.apache.asterix.column.util.ColumnValuesUtil.getNormalizedTypeTag;
 
diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/DatasetConfig.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/DatasetConfig.java
index 3f15eef4f4..dbdddad266 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/DatasetConfig.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/DatasetConfig.java
@@ -21,6 +21,9 @@ package org.apache.asterix.common.config;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
+
 public class DatasetConfig {
 
     /*
@@ -108,8 +111,13 @@ public class DatasetConfig {
             return formats;
         }
 
-        public static DatasetFormat getFormat(String format) {
-            return FORMATS.get(format.trim().toLowerCase());
+        public static DatasetFormat getFormat(String format) throws 
CompilationException {
+            DatasetFormat formatEnum = 
FORMATS.get(format.trim().toLowerCase());
+            if (formatEnum == null) {
+                throw 
CompilationException.create(ErrorCode.UNKNOWN_STORAGE_FORMAT, format);
+            }
+
+            return formatEnum;
         }
     }
 }
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 a49ca551a0..e5c137e63a 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
@@ -291,6 +291,10 @@ public enum ErrorCode implements IError {
     UNSUPPORTED_WRITING_ADAPTER(1188),
     UNSUPPORTED_WRITING_FORMAT(1189),
     COMPUTED_FIELD_CONFLICTING_TYPE(1190),
+    UNSUPPORTED_COLUMN_MERGE_POLICY(1191),
+    UNSUPPORTED_COLUMN_LSM_FILTER(1192),
+    UNKNOWN_STORAGE_FORMAT(1193),
+    UNSUPPORTED_INDEX_IN_COLUMNAR_FORMAT(1194),
 
     // Feed errors
     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 f97b7b6004..d6ff6916fc 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -293,6 +293,10 @@
 1188 = Unsupported writing adapter '%1$s'. Supported adapters: %2$s
 1189 = Unsupported writing format '%1$s'. Supported formats: %2$s
 1190 = A computed field cannot have more than one type. '%1$s' is both '%2$s' 
and 'object'.
+1191 = Merge policy '%1$s' is not supported with columnar storage format
+1192 = Filters are not supported with columnar storage format
+1193 = Unknown storage format '%1$s'
+1194 = Index type '%1$s' is not supported with columnar storage format
 
 # Feed Errors
 3001 = Illegal state.
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 a8d31132c4..ab6097b957 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
@@ -154,7 +154,7 @@ public class DatasetDecl extends AbstractStatement {
     }
 
     public DatasetFormatInfo getDatasetFormatInfo(String defaultFormat, int 
defaultMaxTupleCount,
-            double defaultFreeSpaceTolerance, int defaultMaxLeafNodeSize) {
+            double defaultFreeSpaceTolerance, int defaultMaxLeafNodeSize) 
throws CompilationException {
         if (datasetType != DatasetType.INTERNAL) {
             return DatasetFormatInfo.SYSTEM_DEFAULT;
         }
diff --git 
a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java
 
b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java
index 88fa983bab..276f22beb8 100644
--- 
a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java
+++ 
b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SecondaryIndexOperationsHelper.java
@@ -26,6 +26,7 @@ import java.util.Set;
 import java.util.function.Supplier;
 
 import org.apache.asterix.common.cluster.PartitioningProperties;
+import org.apache.asterix.common.config.DatasetConfig;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.config.OptimizationConfUtil;
 import org.apache.asterix.common.exceptions.CompilationException;
@@ -163,7 +164,8 @@ public abstract class SecondaryIndexOperationsHelper 
implements ISecondaryIndexO
             MetadataProvider metadataProvider, SourceLocation sourceLoc) 
throws AlgebricksException {
 
         ISecondaryIndexOperationsHelper indexOperationsHelper;
-        switch (index.getIndexType()) {
+        DatasetConfig.IndexType indexType = index.getIndexType();
+        switch (indexType) {
             case ARRAY:
                 indexOperationsHelper =
                         new SecondaryArrayIndexBTreeOperationsHelper(dataset, 
index, metadataProvider, sourceLoc);
@@ -172,12 +174,14 @@ public abstract class SecondaryIndexOperationsHelper 
implements ISecondaryIndexO
                 indexOperationsHelper = new 
SecondaryBTreeOperationsHelper(dataset, index, metadataProvider, sourceLoc);
                 break;
             case RTREE:
+                ensureNotColumnar(dataset, indexType, sourceLoc);
                 indexOperationsHelper = new 
SecondaryRTreeOperationsHelper(dataset, index, metadataProvider, sourceLoc);
                 break;
             case SINGLE_PARTITION_WORD_INVIX:
             case SINGLE_PARTITION_NGRAM_INVIX:
             case LENGTH_PARTITIONED_WORD_INVIX:
             case LENGTH_PARTITIONED_NGRAM_INVIX:
+                ensureNotColumnar(dataset, indexType, sourceLoc);
                 indexOperationsHelper =
                         new SecondaryInvertedIndexOperationsHelper(dataset, 
index, metadataProvider, sourceLoc);
                 break;
@@ -192,6 +196,21 @@ public abstract class SecondaryIndexOperationsHelper 
implements ISecondaryIndexO
         return indexOperationsHelper;
     }
 
+    /**
+     * Ensure only supported secondary indexes can be created against dataset
+     * in {@link DatasetConfig.DatasetFormat#COLUMN} format
+     *
+     * @param dataset   primary index
+     * @param indexType secondary index type
+     * @param sourceLoc source location
+     */
+    private static void ensureNotColumnar(Dataset dataset, 
DatasetConfig.IndexType indexType, SourceLocation sourceLoc)
+            throws AlgebricksException {
+        if (dataset.getDatasetFormatInfo().getFormat() == 
DatasetConfig.DatasetFormat.COLUMN) {
+            throw 
CompilationException.create(ErrorCode.UNSUPPORTED_INDEX_IN_COLUMNAR_FORMAT, 
indexType, sourceLoc);
+        }
+    }
+
     @Override
     public abstract JobSpecification buildCreationJobSpec() throws 
AlgebricksException;
 

Reply via email to