This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new e39d234db9 [opt](inverted index) add more check for create inverted
index (#22297)
e39d234db9 is described below
commit e39d234db9aa539692bff5c7cdfe3a295e94d846
Author: YueW <[email protected]>
AuthorDate: Thu Jul 27 20:33:24 2023 +0800
[opt](inverted index) add more check for create inverted index (#22297)
---
.../apache/doris/analysis/InvertedIndexUtil.java | 14 ++++-
.../inverted_index_p0/test_create_index_3.groovy | 72 ++++++++++++++++++++++
2 files changed, 85 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/InvertedIndexUtil.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/InvertedIndexUtil.java
index 294f71dff6..84c99bfa73 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InvertedIndexUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InvertedIndexUtil.java
@@ -50,7 +50,19 @@ public class InvertedIndexUtil {
public static void checkInvertedIndexParser(String indexColName,
PrimitiveType colType,
Map<String, String> properties) throws AnalysisException {
- String parser = getInvertedIndexParser(properties);
+ String parser = null;
+ if (properties != null) {
+ parser = properties.get(INVERTED_INDEX_PARSER_KEY);
+ if (parser == null && !properties.isEmpty()) {
+ throw new AnalysisException("invalid index properties, please
check the properties");
+ }
+ }
+
+ // default is "none" if not set
+ if (parser == null) {
+ parser = INVERTED_INDEX_PARSER_NONE;
+ }
+
if (colType.isStringType()) {
if (!(parser.equals(INVERTED_INDEX_PARSER_NONE)
|| parser.equals(INVERTED_INDEX_PARSER_STANDARD)
diff --git
a/regression-test/suites/inverted_index_p0/test_create_index_3.groovy
b/regression-test/suites/inverted_index_p0/test_create_index_3.groovy
new file mode 100644
index 0000000000..10e7a4a5a7
--- /dev/null
+++ b/regression-test/suites/inverted_index_p0/test_create_index_3.groovy
@@ -0,0 +1,72 @@
+// 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.
+
+
+suite("test_create_index_3", "inverted_index"){
+ // prepare test table
+ def indexTbName1 = "test_create_index_3"
+
+ sql "DROP TABLE IF EXISTS ${indexTbName1}"
+ // case 1: create table with index
+ def create_index_result = "fail"
+ try {
+ sql """
+ CREATE TABLE IF NOT EXISTS ${indexTbName1} (
+ id INT DEFAULT '10',
+ name VARCHAR(32) DEFAULT '',
+ INDEX name_idx(name) USING INVERTED PROPERTIES("parse" =
"english") COMMENT 'name index'
+ )
+ DUPLICATE KEY(id)
+ DISTRIBUTED BY HASH(id) BUCKETS 10
+ PROPERTIES("replication_num" = "1");
+ """
+ create_index_result = "success"
+ } catch(Exception ex) {
+ logger.info("typo for parser , result: " + ex)
+ }
+ assertEquals(create_index_result, "fail")
+
+ // case 2: alter add index
+ sql """
+ CREATE TABLE IF NOT EXISTS ${indexTbName1} (
+ id INT DEFAULT '10',
+ name VARCHAR(32) DEFAULT ''
+ )
+ DUPLICATE KEY(id)
+ DISTRIBUTED BY HASH(id) BUCKETS 10
+ PROPERTIES("replication_num" = "1");
+ """
+
+ try {
+ sql """
+ create index name_idx on ${indexTbName1}(name) using inverted
properties("parse" = "english") comment 'name index';
+ """
+ create_index_result = "success"
+ } catch(Exception ex) {
+ logger.info("typo for parser , result: " + ex)
+ }
+ assertEquals(create_index_result, "fail")
+
+ sql """
+ create index name_idx on ${indexTbName1}(name) using inverted
properties("parser" = "english") comment 'name index';
+ """
+
+ def show_result = sql "show index from ${indexTbName1}"
+ logger.info("show index from " + indexTbName1 + " result: " + show_result)
+ assertEquals(show_result.size(), 1)
+ assertEquals(show_result[0][2], "name_idx")
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]