[fix](agg)disallow group by bitmap or hll data type (#11782)

* [fix](agg)disallow group by bitmap or hll data type
This commit is contained in:
starocean999
2022-08-16 09:25:02 +08:00
committed by GitHub
parent d37cf0a41b
commit f3f1bbc48c
2 changed files with 49 additions and 0 deletions

View File

@ -21,6 +21,7 @@
package org.apache.doris.analysis;
import org.apache.doris.catalog.FunctionSet;
import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.util.VectorizedUtil;
import org.apache.doris.planner.DataPartition;
@ -160,6 +161,14 @@ public final class AggregateInfo extends AggregateInfoBase {
partitionExprs = exprs;
}
private static void validateGroupingExprs(List<Expr> groupingExprs) throws AnalysisException {
for (Expr expr : groupingExprs) {
if (expr.getType().isOnlyMetricType()) {
throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
}
}
}
/**
* Creates complete AggregateInfo for groupingExprs and aggExprs, including
* aggTupleDesc and aggTupleSMap. If parameter tupleDesc != null, sets aggTupleDesc to
@ -176,6 +185,7 @@ public final class AggregateInfo extends AggregateInfoBase {
Preconditions.checkState(
(groupingExprs != null && !groupingExprs.isEmpty())
|| (aggExprs != null && !aggExprs.isEmpty()));
validateGroupingExprs(groupingExprs);
AggregateInfo result = new AggregateInfo(groupingExprs, aggExprs, AggPhase.FIRST);
// collect agg exprs with DISTINCT clause

View File

@ -0,0 +1,39 @@
// 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("aggregate_group_by_hll_and_bitmap") {
sql "DROP TABLE IF EXISTS test_group_by_hll_and_bitmap"
sql """
CREATE TABLE test_group_by_hll_and_bitmap (id int, user_ids bitmap bitmap_union, hll_set hll hll_union)
ENGINE=OLAP DISTRIBUTED BY HASH(`id`) BUCKETS 5 properties("replication_num" = "1");
"""
sql "insert into test_group_by_hll_and_bitmap values(1, bitmap_hash(1), hll_hash(1))"
test {
sql "select distinct user_ids from test_group_by_hll_and_bitmap"
exception "Doris hll and bitmap column must use with specific function, and don't support filter or group by.please run 'help hll' or 'help bitmap' in your mysql client"
}
test {
sql "select distinct hll_set from test_group_by_hll_and_bitmap"
exception "Doris hll and bitmap column must use with specific function, and don't support filter or group by.please run 'help hll' or 'help bitmap' in your mysql client"
}
sql "DROP TABLE test_group_by_hll_and_bitmap"
}