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

imaxon 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 e336845  [NO ISSUE] Fix bug to block illegal inverted index
e336845 is described below

commit e33684506b73368f1f3cd93e82ac03bf9861d21d
Author: Rui Guo <ru...@uci.edu>
AuthorDate: Tue Aug 11 23:25:28 2020 -0700

    [NO ISSUE] Fix bug to block illegal inverted index
    
    Fix bug to block inverted index creation with a variable-length primary
    key (e.g. string as the primary key). Currently, we don't support such
    an inverted index in this case.
    
    Change-Id: I715d55d48246fd08817b72f7104bc4d436578600
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/7523
    Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Ian Maxon <ima...@uci.edu>
---
 .../asterix/app/translator/QueryTranslator.java    |  2 +-
 ...ex-with-variable-length-primary-key.1.ddl.sqlpp | 33 ++++++++++++++++++++++
 .../test/resources/runtimets/testsuite_sqlpp.xml   |  6 ++++
 3 files changed, 40 insertions(+), 1 deletion(-)

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 04a2f2d..1c9bfb3 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
@@ -1095,7 +1095,7 @@ public class QueryTranslator extends 
AbstractLangTranslator implements IStatemen
                     ITypeTraits typeTrait = 
TypeTraitProvider.INSTANCE.getTypeTrait(keyType);
 
                     // If it is not a fixed length
-                    if (typeTrait.getFixedLength() < 0) {
+                    if (!typeTrait.isFixedLength()) {
                         throw new 
CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                                 "The keyword or ngram index -" + indexName + " 
cannot be created on the dataset -"
                                         + datasetName + " due to its 
variable-length primary key field - "
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-index/create-inverted-index-with-variable-length-primary-key/create-inverted-index-with-variable-length-primary-key.1.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-index/create-inverted-index-with-variable-length-primary-key/create-inverted-index-with-variable-length-primary-key.1.ddl.sqlpp
new file mode 100644
index 0000000..d6e9bbb
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/ddl/create-index/create-inverted-index-with-variable-length-primary-key/create-inverted-index-with-variable-length-primary-key.1.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+DROP DATAVERSE MyDataverse IF EXISTS;
+CREATE DATAVERSE MyDataverse;
+USE MyDataverse;
+
+DROP TYPE MyDataset IF EXISTS;
+CREATE TYPE MyDataType AS OPEN
+{ myKey: string, myValue: string? };
+
+DROP DATASET MyDataset IF EXISTS;
+CREATE DATASET MyDataset(MyDataType) PRIMARY KEY myKey;
+
+DROP INDEX MyDataset.MyIndex IF EXISTS;
+// should fail because inverted index with a variable length primary key are 
not supported yet
+CREATE INDEX MyIndex ON MyDataset(myValue) type fulltext;
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index e04f341..19f5614 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3967,6 +3967,12 @@
         <expected-error>Syntax error: In line 53 >>create  primary index if 
exists sec_primary_idx1  on LineItem;&lt;&lt; Encountered "exists" at column 
26.</expected-error>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="ddl/create-index">
+      <compilation-unit 
name="create-inverted-index-with-variable-length-primary-key">
+        <output-dir 
compare="Text">create-inverted-index-with-variable-length-primary-key</output-dir>
+        <expected-error>ASX1079: Compilation error: The keyword or ngram index 
-MyIndex cannot be created on the dataset -MyDataset due to its variable-length 
primary key field - [myKey] (in line 33, at column 1)</expected-error>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="ddl">
       <compilation-unit name="bad-type-ddl">
         <output-dir compare="Text">none</output-dir>

Reply via email to