Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ public void validate() {
AnnIndexPropertiesChecker.checkProperties(this.properties);
}

if (indexType == IndexType.BITMAP || indexType == IndexType.INVERTED) {
if (indexType == IndexType.BITMAP || indexType == IndexType.INVERTED
|| indexType == IndexType.NGRAM_BF) {
if (cols == null || cols.size() != 1) {
throw new AnalysisException(
indexType.toString() + " index can only apply to a single column.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ void testNgramBFIndex() throws AnalysisException {
KeysType.DUP_KEYS, false, null);
}

@Test
void testNgramBFIndexOnlySingleColumn() {
IndexDefinition def = new IndexDefinition("ngram_bf_index", false, Lists.newArrayList("col1", "col2"),
"NGRAM_BF", null, "comment");
AnalysisException exception = Assertions.assertThrows(AnalysisException.class, def::validate);
Assertions.assertEquals("NGRAM_BF index can only apply to a single column.", exception.getMessage());
}

@Test
void testInvalidNgramBFIndexColumnType() {
Map<String, String> properties = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,41 @@ suite("test_ngram_bloomfilter_index") {
sql """ALTER TABLE ${tableName3} ADD INDEX idx_http_url(http_url) USING NGRAM_BF PROPERTIES("gram_size"="256", "bf_size"="65535") COMMENT 'http_url ngram_bf index'"""
exception "java.sql.SQLException: errCode = 2, detailMessage = 'gram_size' should be an integer between 1 and 255."
}

sql "DROP TABLE IF EXISTS test_ngram_bloomfilter_multi_column_index"
test {
sql """
CREATE TABLE test_ngram_bloomfilter_multi_column_index (
`key_id` bigint(20) NULL COMMENT '',
`http_url` text NULL COMMENT '',
`url_path` varchar(2000) NULL COMMENT '',
INDEX idx_ngrambf_multi (`http_url`, `url_path`) USING NGRAM_BF
PROPERTIES("gram_size" = "2", "bf_size" = "512")
) ENGINE=OLAP
DUPLICATE KEY(`key_id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`key_id`) BUCKETS 1
PROPERTIES("replication_num" = "1");
"""
exception "NGRAM_BF index can only apply to a single column."
}

sql """
CREATE TABLE test_ngram_bloomfilter_multi_column_index (
`key_id` bigint(20) NULL COMMENT '',
`http_url` text NULL COMMENT '',
`url_path` varchar(2000) NULL COMMENT ''
) ENGINE=OLAP
DUPLICATE KEY(`key_id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`key_id`) BUCKETS 1
PROPERTIES("replication_num" = "1");
"""
test {
sql """
CREATE INDEX idx_ngrambf_multi ON test_ngram_bloomfilter_multi_column_index(`http_url`, `url_path`)
USING NGRAM_BF PROPERTIES("gram_size" = "2", "bf_size" = "512")
"""
exception "NGRAM_BF index can only apply to a single column."
}
}
Loading