Skip to content

Commit

Permalink
[fix](bloomFilter)fix data type supported behavior same in FE and BE (#…
Browse files Browse the repository at this point in the history
…42416)

fix create table stmt for properties: bloom_filter_columns, which should
same with BE behavior
  • Loading branch information
amorynan authored and airborne12 committed Dec 9, 2024
1 parent 0bd1aba commit edffa4f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
14 changes: 14 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,20 @@ public boolean isVersionColumn() {
|| aggregationType == AggregateType.NONE) && nameEquals(VERSION_COL, true);
}

// now we only support BloomFilter on (same behavior with BE):
// smallint/int/bigint/largeint
// string/varchar/char/variant
// date/datetime/datev2/datetimev2
// decimal/decimal32/decimal64/decimal128I/decimal256
// ipv4/ipv6
public boolean isSupportBloomFilter() {
PrimitiveType pType = getDataType();
return (pType == PrimitiveType.SMALLINT || pType == PrimitiveType.INT
|| pType == PrimitiveType.BIGINT || pType == PrimitiveType.LARGEINT)
|| pType.isCharFamily() || pType.isDateType() || pType.isVariantType()
|| pType.isDecimalV2Type() || pType.isDecimalV3Type() || pType.isIPType();
}

public PrimitiveType getDataType() {
return type.getPrimitiveType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,8 @@ public static Set<String> analyzeBloomFilterColumns(Map<String, String> properti
if (column.getName().equalsIgnoreCase(bfColumn)) {
PrimitiveType type = column.getDataType();

// tinyint/float/double columns don't support
// key columns and none/replace aggregate non-key columns support
if (type == PrimitiveType.TINYINT || type == PrimitiveType.FLOAT
|| type == PrimitiveType.DOUBLE || type == PrimitiveType.BOOLEAN
|| type.isComplexType()) {
if (!column.isSupportBloomFilter()) {
throw new AnalysisException(type + " is not supported in bloom filter index. "
+ "invalid column: " + bfColumn);
} else if (keysType != KeysType.AGG_KEYS || column.isKey()) {
Expand Down
33 changes: 33 additions & 0 deletions regression-test/suites/bloom_filter_p0/test_bloom_filter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,37 @@ suite("test_bloom_filter") {
sql """ALTER TABLE ${test_map_tb} SET("bloom_filter_columns" = "k1,m1")"""
exception "not supported in bloom filter index"
}

// bloom filter index for json column
def test_json_tb = "test_json_bloom_filter_tb"
sql """DROP TABLE IF EXISTS ${test_json_tb}"""

test {
sql """CREATE TABLE IF NOT EXISTS ${test_json_tb} (
`k1` int(11) NOT NULL,
`j1` json NOT NULL
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
DISTRIBUTED BY HASH(`k1`) BUCKETS 5
PROPERTIES (
"replication_num" = "1",
"bloom_filter_columns" = "k1,j1"
)"""
exception "not supported in bloom filter index"
}

sql """CREATE TABLE IF NOT EXISTS ${test_json_tb} (
`k1` int(11) NOT NULL,
`j1` json NOT NULL
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
DISTRIBUTED BY HASH(`k1`) BUCKETS 5
PROPERTIES (
"replication_num" = "1",
"bloom_filter_columns" = "k1"
)"""
test {
sql """ALTER TABLE ${test_json_tb} SET("bloom_filter_columns" = "k1,j1")"""
exception "not supported in bloom filter index"
}
}

0 comments on commit edffa4f

Please sign in to comment.