This is an automated email from the ASF dual-hosted git repository. jianliangqi 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 410907c940 [improvement](inverted index)UNIQUE_KEYS table only supports inverted index when merge_on_write is enabled. (#17827) 410907c940 is described below commit 410907c940a185a00b8c3c975ff5a799c9303eac Author: qiye <jianliang5...@gmail.com> AuthorDate: Wed Mar 22 17:47:30 2023 +0800 [improvement](inverted index)UNIQUE_KEYS table only supports inverted index when merge_on_write is enabled. (#17827) When adding inverted index to UNIQUE_KEYS table without merge_on_write enabled, the match query may failed before the segment is compacted. So we add the restriction here. --- .../apache/doris/alter/SchemaChangeHandler.java | 3 ++- .../org/apache/doris/analysis/CreateTableStmt.java | 2 +- .../java/org/apache/doris/analysis/IndexDef.java | 24 +++++++++++----------- .../doris/alter/SchemaChangeHandlerTest.java | 3 ++- .../suites/mysql_fulltext/ddl/articles_uk.sql | 3 ++- .../suites/mysql_fulltext/ddl/fulltext_t1_uk.sql | 3 ++- .../suites/mysql_fulltext/ddl/join_t1_uk.sql | 3 ++- .../suites/mysql_fulltext/ddl/join_t2_uk.sql | 3 ++- .../mysql_fulltext/ddl/large_records_t1_uk.sql | 3 ++- .../mysql_fulltext/ddl/large_records_t2_uk.sql | 3 ++- .../mysql_fulltext/ddl/large_records_t3_uk.sql | 3 ++- .../mysql_fulltext/ddl/large_records_t4_uk.sql | 3 ++- 12 files changed, 33 insertions(+), 23 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java index 5dfdb6c55f..60dec875bc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java @@ -2206,7 +2206,8 @@ public class SchemaChangeHandler extends AlterHandler { for (String col : indexDef.getColumns()) { Column column = olapTable.getColumn(col); if (column != null) { - indexDef.checkColumn(column, olapTable.getKeysType()); + indexDef.checkColumn(column, olapTable.getKeysType(), + olapTable.getTableProperty().getEnableUniqueKeyMergeOnWrite()); } else { throw new DdlException("index column does not exist in table. invalid column: " + col); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java index 0af2f8bb2a..938c937bef 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java @@ -552,7 +552,7 @@ public class CreateTableStmt extends DdlStmt { boolean found = false; for (Column column : columns) { if (column.getName().equalsIgnoreCase(indexColName)) { - indexDef.checkColumn(column, getKeysDesc().getKeysType()); + indexDef.checkColumn(column, getKeysDesc().getKeysType(), enableUniqueKeyMergeOnWrite); found = true; break; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/IndexDef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/IndexDef.java index 711a83496b..a5eb735b1d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/IndexDef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/IndexDef.java @@ -179,7 +179,8 @@ public class IndexDef { return (this.indexType == IndexType.INVERTED); } - public void checkColumn(Column column, KeysType keysType) throws AnalysisException { + public void checkColumn(Column column, KeysType keysType, boolean enableUniqueKeyMergeOnWrite) + throws AnalysisException { if (indexType == IndexType.BITMAP || indexType == IndexType.INVERTED || indexType == IndexType.BLOOMFILTER || indexType == IndexType.NGRAM_BF) { String indexColName = column.getName(); @@ -192,10 +193,17 @@ public class IndexDef { || colType.isFixedPointType() || colType.isStringType() || colType == PrimitiveType.BOOLEAN)) { throw new AnalysisException(colType + " is not supported in " + indexType.toString() + " index. " + "invalid column: " + indexColName); - } else if ((keysType == KeysType.AGG_KEYS && !column.isKey())) { + } else if (indexType == IndexType.INVERTED + && ((keysType == KeysType.AGG_KEYS && !column.isKey()) + || (keysType == KeysType.UNIQUE_KEYS && !enableUniqueKeyMergeOnWrite))) { throw new AnalysisException(indexType.toString() - + " index only used in columns of DUP_KEYS/UNIQUE_KEYS table or key columns of" - + " AGG_KEYS table. invalid column: " + indexColName); + + " index only used in columns of DUP_KEYS table" + + " or UNIQUE_KEYS table with merge_on_write enabled" + + " or key columns of AGG_KEYS table. invalid column: " + indexColName); + } else if (keysType == KeysType.AGG_KEYS && !column.isKey() && indexType != IndexType.INVERTED) { + throw new AnalysisException(indexType.toString() + + " index only used in columns of DUP_KEYS/UNIQUE_KEYS table or key columns of" + + " AGG_KEYS table. invalid column: " + indexColName); } if (indexType == IndexType.INVERTED) { @@ -230,12 +238,4 @@ public class IndexDef { throw new AnalysisException("Unsupported index type: " + indexType); } } - - public void checkColumns(List<Column> columns, KeysType keysType) throws AnalysisException { - if (indexType == IndexType.BITMAP || indexType == IndexType.INVERTED || indexType == IndexType.BLOOMFILTER) { - for (Column col : columns) { - checkColumn(col, keysType); - } - } - } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java b/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java index 37b96283ea..8b402a1339 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/alter/SchemaChangeHandlerTest.java @@ -65,7 +65,8 @@ public class SchemaChangeHandlerTest extends TestWithFeService { + "username VARCHAR(50) NOT NULL,\n" + "city VARCHAR(20),\n" + "age SMALLINT,\n" + "sex TINYINT,\n" + "phone LARGEINT,\n" + "address VARCHAR(500),\n" + "register_time DATETIME)\n" + "UNIQUE KEY(user_id, username)\n" + "DISTRIBUTED BY HASH(user_id) BUCKETS 1\n" - + "PROPERTIES ('replication_num' = '1', 'light_schema_change' = 'true');"; + + "PROPERTIES ('replication_num' = '1', 'light_schema_change' = 'true',\n" + + "'enable_unique_key_merge_on_write' = 'true');"; createTable(createUniqTblStmtStr); String createDupTblStmtStr = "CREATE TABLE IF NOT EXISTS test.sc_dup (\n" + "timestamp DATETIME,\n" diff --git a/regression-test/suites/mysql_fulltext/ddl/articles_uk.sql b/regression-test/suites/mysql_fulltext/ddl/articles_uk.sql index 6d4d82ca26..2cf464d2e6 100644 --- a/regression-test/suites/mysql_fulltext/ddl/articles_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/articles_uk.sql @@ -8,5 +8,6 @@ CREATE TABLE IF NOT EXISTS articles_uk ( UNIQUE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); \ No newline at end of file diff --git a/regression-test/suites/mysql_fulltext/ddl/fulltext_t1_uk.sql b/regression-test/suites/mysql_fulltext/ddl/fulltext_t1_uk.sql index 8ea21fc85f..384c390a28 100644 --- a/regression-test/suites/mysql_fulltext/ddl/fulltext_t1_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/fulltext_t1_uk.sql @@ -7,5 +7,6 @@ CREATE TABLE IF NOT EXISTS fulltext_t1_uk ( UNIQUE KEY(a) DISTRIBUTED BY HASH(a) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); \ No newline at end of file diff --git a/regression-test/suites/mysql_fulltext/ddl/join_t1_uk.sql b/regression-test/suites/mysql_fulltext/ddl/join_t1_uk.sql index 955c42311b..41c2a27ea3 100644 --- a/regression-test/suites/mysql_fulltext/ddl/join_t1_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/join_t1_uk.sql @@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS join_t1_uk ( UNIQUE KEY(venue_id) DISTRIBUTED BY HASH(venue_id) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); diff --git a/regression-test/suites/mysql_fulltext/ddl/join_t2_uk.sql b/regression-test/suites/mysql_fulltext/ddl/join_t2_uk.sql index fb1ab497b5..a217c3962c 100644 --- a/regression-test/suites/mysql_fulltext/ddl/join_t2_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/join_t2_uk.sql @@ -6,5 +6,6 @@ CREATE TABLE IF NOT EXISTS join_t2_uk ( UNIQUE KEY(entity_id) DISTRIBUTED BY HASH(entity_id) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); \ No newline at end of file diff --git a/regression-test/suites/mysql_fulltext/ddl/large_records_t1_uk.sql b/regression-test/suites/mysql_fulltext/ddl/large_records_t1_uk.sql index ac1039fd7c..4b92113904 100644 --- a/regression-test/suites/mysql_fulltext/ddl/large_records_t1_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/large_records_t1_uk.sql @@ -8,5 +8,6 @@ CREATE TABLE IF NOT EXISTS large_records_t1_uk ( UNIQUE KEY(FTS_DOC_ID) DISTRIBUTED BY HASH(FTS_DOC_ID) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); \ No newline at end of file diff --git a/regression-test/suites/mysql_fulltext/ddl/large_records_t2_uk.sql b/regression-test/suites/mysql_fulltext/ddl/large_records_t2_uk.sql index 0f36cb135b..733c398ccc 100644 --- a/regression-test/suites/mysql_fulltext/ddl/large_records_t2_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/large_records_t2_uk.sql @@ -8,5 +8,6 @@ CREATE TABLE IF NOT EXISTS large_records_t2_uk ( UNIQUE KEY(FTS_DOC_ID) DISTRIBUTED BY HASH(FTS_DOC_ID) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); \ No newline at end of file diff --git a/regression-test/suites/mysql_fulltext/ddl/large_records_t3_uk.sql b/regression-test/suites/mysql_fulltext/ddl/large_records_t3_uk.sql index cd49547e7d..e46c254da7 100644 --- a/regression-test/suites/mysql_fulltext/ddl/large_records_t3_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/large_records_t3_uk.sql @@ -8,5 +8,6 @@ CREATE TABLE IF NOT EXISTS large_records_t3_uk ( UNIQUE KEY(FTS_DOC_ID) DISTRIBUTED BY HASH(FTS_DOC_ID) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); \ No newline at end of file diff --git a/regression-test/suites/mysql_fulltext/ddl/large_records_t4_uk.sql b/regression-test/suites/mysql_fulltext/ddl/large_records_t4_uk.sql index 9689721bcd..b594d5cd3c 100644 --- a/regression-test/suites/mysql_fulltext/ddl/large_records_t4_uk.sql +++ b/regression-test/suites/mysql_fulltext/ddl/large_records_t4_uk.sql @@ -8,5 +8,6 @@ CREATE TABLE IF NOT EXISTS large_records_t4_uk ( UNIQUE KEY(FTS_DOC_ID) DISTRIBUTED BY HASH(FTS_DOC_ID) BUCKETS 3 PROPERTIES ( - "replication_num" = "1" + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" ); \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org