Full-text implementation step 4
- Follows the new error handling proposal.
- Introduces Full-TextTypeComputer.
Change-Id: Ib909882c43a3fc1401eceec1e1ddd981f40b6dee
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1422
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
index 2e6518b..189f37e 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
@@ -28,6 +28,8 @@
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.common.config.DatasetConfig.IndexType;
import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.CompilationException;
+import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.external.indexing.IndexingConstants;
import org.apache.asterix.lang.common.util.FunctionUtil;
import org.apache.asterix.metadata.declared.DataSourceId;
@@ -204,7 +206,8 @@
argValue = ConstantExpressionUtil.getStringConstant(element);
checkAndGenerateFTSearchExceptionForStringPhrase(argValue);
} else {
- throw new AlgebricksException("Each element in the list should be a string in the Full-text search.");
+ throw new CompilationException(ErrorCode.COMPILATION_TYPE_UNSUPPORTED,
+ BuiltinFunctions.FULLTEXT_CONTAINS.getName(), element.getType().getTypeTag());
}
}
}
@@ -230,8 +233,8 @@
checkEachElementInFTSearchListPredicate(oListCursor);
break;
default:
- throw new AlgebricksException(
- "A full-text Search predicate should be a string or an (un)ordered list.");
+ throw new CompilationException(ErrorCode.COMPILATION_TYPE_UNSUPPORTED,
+ BuiltinFunctions.FULLTEXT_CONTAINS.getName(), objectFromExpr.getType().getTypeTag());
}
}
@@ -240,9 +243,7 @@
public static void checkAndGenerateFTSearchExceptionForStringPhrase(String value) throws AlgebricksException {
for (int j = 0; j < value.length(); j++) {
if (DelimitedUTF8StringBinaryTokenizer.isSeparator(value.charAt(j))) {
- throw new AlgebricksException(
- "Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted."
- + value.charAt(j));
+ throw new CompilationException(ErrorCode.COMPILATION_FULLTEXT_PHRASE_FOUND);
}
}
}
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains-without-option.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains-without-option.aql
index eee411c..3c924f9 100644
--- a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains-without-option.aql
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains-without-option.aql
@@ -47,8 +47,6 @@
create index fulltext_index_title on MyData(title) type fulltext;
-write output to asterix_nc1:"rttest/inverted-index-basic_fulltext-contains-without-option.adm";
-
for $o in dataset MyData
where ftcontains($o.title, "database")
order by $o.id
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains.aql b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains.aql
index bc697df..3ef8cd8 100644
--- a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains.aql
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/inverted-index-basic/fulltext-contains.aql
@@ -47,8 +47,6 @@
create index fulltext_index_title on MyData(title) type fulltext;
-write output to asterix_nc1:"rttest/inverted-index-basic_fulltext-contains.adm";
-
for $o in dataset MyData
where ftcontains($o.title, "database", {"mode":"any"})
order by $o.id
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.1.ddl.aql
index 14cda48..d961d27 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.1.ddl.aql
@@ -20,7 +20,7 @@
/*
* Description : Full-text search non-index test
* : This test is intended to verify that the full-text search DOES NOT work as expected.
- * : query #3 - a string phrase is provided as a query predicate.
+ * : query #2 - a string phrase is provided as a query predicate.
* : this should throw an exception since we don't support a phrase search yet.
* Expected Result : Exception
*
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.2.query.aql
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.3.query.aql
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.2.query.aql
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.2.update.aql
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-04/fulltext-04.2.update.aql
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-05/fulltext-05.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-05/fulltext-05.2.query.aql
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-05/fulltext-05.3.query.aql
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-05/fulltext-05.2.query.aql
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-05/fulltext-05.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-05/fulltext-05.2.update.aql
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-05/fulltext-05.2.update.aql
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-06/fulltext-06.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-06/fulltext-06.2.query.aql
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-06/fulltext-06.3.query.aql
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-06/fulltext-06.2.query.aql
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-06/fulltext-06.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-06/fulltext-06.2.update.aql
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-06/fulltext-06.2.update.aql
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.1.ddl.aql
index 5664ee9..7d62aeb 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.1.ddl.aql
@@ -20,7 +20,7 @@
/*
* Description : Full-text search index test
* : This test is intended to verify that the full-text search DOES NOT work as expected.
- * : query #3 - a string phrase is provided as a query predicate.
+ * : query #2 - a string phrase is provided as a query predicate.
* : this should throw an exception since we don't support a phrase search yet.
* Expected Result : Exception
*
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.2.query.aql
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.3.query.aql
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.2.query.aql
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.2.update.aql
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-04/fulltext-index-04.2.update.aql
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.1.ddl.aql
index 07ebb6c..d34bae3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.1.ddl.aql
@@ -20,7 +20,7 @@
/*
* Description : Full-text search index test
* : This test is intended to verify that the full-text search DOES NOT work as expected.
- * : query #3 - a string phrase in an ordered list is provided as a query predicate.
+ * : query #2 - a string phrase in an ordered list is provided as a query predicate.
* : this should throw an exception since we don't support a phrase search yet.
* Expected Result : Exception
*
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.2.query.aql
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.3.query.aql
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.2.query.aql
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.2.update.aql
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-05/fulltext-index-05.2.update.aql
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.1.ddl.aql
index 7295edf..f45d679 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.1.ddl.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.1.ddl.aql
@@ -20,7 +20,7 @@
/*
* Description : Full-text search index test
* : This test is intended to verify that the full-text search DOES NOT work as expected.
- * : query #3 - a string phrase in an unordered list is provided as a query predicate.
+ * : query #2 - a string phrase in an unordered list is provided as a query predicate.
* : this should throw an exception since we don't support a phrase search yet.
* Expected Result : Exception
*
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.2.query.aql
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.3.query.aql
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.2.query.aql
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.2.update.aql
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/fulltext/fulltext-index-06/fulltext-index-06.2.update.aql
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-04/fulltext-04.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-04/fulltext-04.2.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-04/fulltext-04.3.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-04/fulltext-04.2.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-05/fulltext-05.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-05/fulltext-05.2.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-05/fulltext-05.3.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-05/fulltext-05.2.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-06/fulltext-06.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-06/fulltext-06.2.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-06/fulltext-06.3.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-06/fulltext-06.2.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-04/fulltext-index-04.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-04/fulltext-index-04.2.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-04/fulltext-index-04.3.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-04/fulltext-index-04.2.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-05/fulltext-index-05.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-05/fulltext-index-05.2.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-05/fulltext-index-05.3.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-05/fulltext-index-05.2.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-06/fulltext-index-06.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-06/fulltext-index-06.2.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-06/fulltext-index-06.3.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/fulltext/fulltext-index-06/fulltext-index-06.2.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index dfb6303..2ee3a2c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -400,19 +400,19 @@
<test-case FilePath="fulltext">
<compilation-unit name="fulltext-04">
<output-dir compare="Text">fulltext-04</output-dir>
- <expected-error>Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted. </expected-error>
+ <expected-error>ASX1010: Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="fulltext">
<compilation-unit name="fulltext-05">
<output-dir compare="Text">fulltext-05</output-dir>
- <expected-error>Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted. </expected-error>
+ <expected-error>ASX1010: Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="fulltext">
<compilation-unit name="fulltext-06">
<output-dir compare="Text">fulltext-06</output-dir>
- <expected-error>Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted. </expected-error>
+ <expected-error>ASX1010: Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="fulltext">
@@ -438,19 +438,19 @@
<test-case FilePath="fulltext">
<compilation-unit name="fulltext-index-04">
<output-dir compare="Text">fulltext-index-04</output-dir>
- <expected-error>Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted. </expected-error>
+ <expected-error>ASX1010: Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="fulltext">
<compilation-unit name="fulltext-index-05">
<output-dir compare="Text">fulltext-index-05</output-dir>
- <expected-error>Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted. </expected-error>
+ <expected-error>ASX1010: Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="fulltext">
<compilation-unit name="fulltext-index-06">
<output-dir compare="Text">fulltext-index-06</output-dir>
- <expected-error>Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted. </expected-error>
+ <expected-error>ASX1010: Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="fulltext">
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 1289787..fad00a7 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
@@ -63,6 +63,7 @@
public static final int COMPILATION_INVALID_EXPRESSION = 1007;
public static final int COMPILATION_INVALID_PARAMETER_NUMBER = 1008;
public static final int COMPILATION_INVALID_RETURNING_EXPRESSION = 1009;
+ public static final int COMPILATION_FULLTEXT_PHRASE_FOUND = 1010;
// Feed errors
public static final int DATAFLOW_ILLEGAL_STATE = 3001;
@@ -144,7 +145,6 @@
public static final int UTIL_LOCAL_FILE_SYSTEM_UTILS_PATH_NOT_FOUND = 3077;
public static final int UTIL_HDFS_UTILS_CANNOT_OBTAIN_HDFS_SCHEDULER = 3078;
-
// Loads the map that maps error codes to error message templates.
private static Map<Integer, String> errorMessageMap = null;
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 c072f16..f0e98c9 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -48,6 +48,7 @@
# Compile-time check errors
1007 = Invalid expression: function %1$s expects its %2$s input parameter to be a %3$s expression, but the actual expression is %4$s
1008 = Invalid parameter number: function %1$s cannot take %2$s parameters
+1010 = Phrase search in Full-text is not yet supported. Only one keyword per expression is permitted
# Feed Errors
3001 = Illegal state.
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
index 3f3a5bd..6eaf4ae 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
@@ -64,6 +64,7 @@
import org.apache.asterix.om.typecomputer.impl.FieldAccessByIndexResultType;
import org.apache.asterix.om.typecomputer.impl.FieldAccessByNameResultType;
import org.apache.asterix.om.typecomputer.impl.FieldAccessNestedResultType;
+import org.apache.asterix.om.typecomputer.impl.FullTextContainsResultTypeComputer;
import org.apache.asterix.om.typecomputer.impl.GetOverlappingInvervalTypeComputer;
import org.apache.asterix.om.typecomputer.impl.InjectFailureTypeComputer;
import org.apache.asterix.om.typecomputer.impl.LocalAvgTypeComputer;
@@ -1035,8 +1036,8 @@
addPrivateFunction(SIMILARITY_JACCARD_PREFIX_CHECK, OrderedListOfAnyTypeComputer.INSTANCE, true);
// Full-text function
- addFunction(FULLTEXT_CONTAINS, ABooleanTypeComputer.INSTANCE, true);
- addFunction(FULLTEXT_CONTAINS_WO_OPTION, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(FULLTEXT_CONTAINS, FullTextContainsResultTypeComputer.INSTANCE, true);
+ addFunction(FULLTEXT_CONTAINS_WO_OPTION, FullTextContainsResultTypeComputer.INSTANCE, true);
// Spatial functions
addFunction(SPATIAL_AREA, ADoubleTypeComputer.INSTANCE, true);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FullTextContainsResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FullTextContainsResultTypeComputer.java
new file mode 100644
index 0000000..f2398e1
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FullTextContainsResultTypeComputer.java
@@ -0,0 +1,63 @@
+/*
+ * 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.om.typecomputer.impl;
+
+import org.apache.asterix.om.exceptions.TypeMismatchException;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+
+public class FullTextContainsResultTypeComputer extends AbstractResultTypeComputer {
+
+ public static final FullTextContainsResultTypeComputer INSTANCE = new FullTextContainsResultTypeComputer();
+
+ private FullTextContainsResultTypeComputer() {
+ }
+
+ @Override
+ protected void checkArgType(String funcName, int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag actualTypeTag = type.getTypeTag();
+ // Expression1 should be a string.
+ if (argIndex == 0 && actualTypeTag != ATypeTag.STRING && actualTypeTag != ATypeTag.ANY) {
+ throw new TypeMismatchException(funcName, argIndex, actualTypeTag, ATypeTag.STRING);
+ }
+ // Expression2 should be a string, or an (un)ordered list.
+ if (argIndex == 1 && (actualTypeTag != ATypeTag.STRING && actualTypeTag != ATypeTag.UNORDEREDLIST
+ && actualTypeTag != ATypeTag.ORDEREDLIST && actualTypeTag != ATypeTag.ANY)) {
+ throw new TypeMismatchException(funcName, argIndex, actualTypeTag, ATypeTag.STRING, ATypeTag.UNORDEREDLIST,
+ ATypeTag.ORDEREDLIST);
+ }
+ // Each option name should be a string if it is already processed by FullTextContainsParameterCheckRule.
+ // Before, the third argument should be a record if exists.
+ // The structure is: arg2 = optionName1, arg3 = optionValue1, arg4 = optionName1, arg5 = optionValue2, ...
+ if (argIndex > 1 && argIndex % 2 == 0 && (actualTypeTag != ATypeTag.STRING && actualTypeTag != ATypeTag.RECORD
+ && actualTypeTag != ATypeTag.ANY)) {
+ throw new TypeMismatchException(funcName, argIndex, actualTypeTag, ATypeTag.STRING, ATypeTag.RECORD);
+ }
+ }
+
+ @Override
+ protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException {
+ return BuiltinType.ABOOLEAN;
+ }
+
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
index 95f2e8e..888f82a 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
@@ -34,6 +34,8 @@
public static final int INVALID_OPERATOR_OPERATION = 1;
public static final int ERROR_PROCESSING_TUPLE = 2;
public static final int FAILURE_ON_NODE = 3;
+ public static final int RUNTIME_FILE_WITH_ABSOULTE_PATH_NOT_WITHIN_ANY_IO_DEVICE = 4;
+ public static final int RUNTIME_FULLTEXT_PHRASE_FOUND = 5;
// Loads the map that maps error codes to error message templates.
private static Map<Integer, String> errorMessageMap = null;
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
index 890021b..8ebafef 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
@@ -19,3 +19,5 @@
1=Unsupported operation %1$s in %2$s operator
2=Error in processing tuple %1$s in a frame
+4=The file with absolute path %1$s is not within any of the current IO devices
+5=Phrase search in Full-text is not supported. An expression should include only one word
\ No newline at end of file
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java
index 352f912..cb38076 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.concurrent.Executor;
+import org.apache.hyracks.api.exceptions.ErrorCode;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.io.FileReference;
import org.apache.hyracks.api.io.IFileDeviceComputer;
@@ -338,17 +339,11 @@
return new FileReference(deviceComputer.compute(path), path);
}
- // Temp:
@Override
public FileReference resolveAbsolutePath(String path) throws HyracksDataException {
IODeviceHandle devHandle = getDevice(path);
if (devHandle == null) {
- String errorMessage = "The file with absolute path: " + path
- + " is outside all IO devices. IO devices in this node are \n";
- for (IODeviceHandle d : ioDevices) {
- errorMessage = errorMessage.concat(d.toString() + '\n');
- }
- throw new HyracksDataException(errorMessage);
+ throw HyracksDataException.create(ErrorCode.RUNTIME_FILE_WITH_ABSOULTE_PATH_NOT_WITHIN_ANY_IO_DEVICE, path);
}
String relativePath = devHandle.getRelativePath(path);
return new FileReference(devHandle, relativePath);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/search/AbstractTOccurrenceSearcher.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/search/AbstractTOccurrenceSearcher.java
index cfc9fc6..9e6afa7 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/search/AbstractTOccurrenceSearcher.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/search/AbstractTOccurrenceSearcher.java
@@ -29,6 +29,7 @@
import org.apache.hyracks.api.context.IHyracksCommonContext;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
+import org.apache.hyracks.api.exceptions.ErrorCode;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.IntegerPointable;
import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
@@ -121,16 +122,12 @@
// If it's a list, it can have multiple keywords in it. But, each keyword should not be a phrase.
if (isFullTextSearchQuery) {
if (queryTokenizerType == TokenizerType.STRING && tokenCountInOneField > 1) {
- throw new HyracksDataException(
- "Phrase search in Full-text is not supported. "
- + "An expression should include only one word.");
+ throw HyracksDataException.create(ErrorCode.RUNTIME_FULLTEXT_PHRASE_FOUND);
} else if (queryTokenizerType == TokenizerType.LIST) {
for (int j = 1; j < token.getTokenLength(); j++) {
if (DelimitedUTF8StringBinaryTokenizer
.isSeparator((char) token.getData()[token.getStartOffset() + j])) {
- throw new HyracksDataException(
- "Phrase search in Full-text is not supported. "
- + "An expression should include only one word.");
+ throw HyracksDataException.create(ErrorCode.RUNTIME_FULLTEXT_PHRASE_FOUND);
}
}
}