Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonLiTree committed Dec 5, 2023
1 parent cd958be commit 2ca88df
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.BitmapType;
import org.apache.doris.nereids.types.CharType;
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.FloatType;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.types.SmallIntType;
import org.apache.doris.nereids.types.StringType;
import org.apache.doris.nereids.types.TinyIntType;
import org.apache.doris.nereids.util.ExpressionUtils;

import com.google.common.base.Preconditions;
Expand All @@ -39,11 +46,15 @@
public class IntersectCount extends AggregateFunction
implements ExplicitlyCastableSignature, AlwaysNotNullable, BitmapIntersectFunction {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE)
.varArgs(BitmapType.INSTANCE, StringType.INSTANCE, StringType.INSTANCE)
List<DataType> SUPPORTED_TYPES = ImmutableList.of(
SmallIntType.INSTANCE, TinyIntType.INSTANCE, IntegerType.INSTANCE, BigIntType.INSTANCE,
FloatType.INSTANCE, DoubleType.INSTANCE, StringType.INSTANCE, CharType.SYSTEM_DEFAULT
);

List<FunctionSignature> SIGNATURES = SUPPORTED_TYPES.stream()
.map(type -> FunctionSignature.ret(BigIntType.INSTANCE).varArgs(BitmapType.INSTANCE, type, type))
.collect(ImmutableList.toImmutableList());

/**
* constructor with 3 or more arguments.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,11 @@ true
9999999999

-- !sql --
4 1,2,3
3 1,2,3,4,5
4 2022-10-14 1,2,3
3 2022-10-13 1,2,3,4,5

-- !sql --
3

-- !sql --
3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,20 +580,21 @@ suite("test_bitmap_function") {
// INTERSECT_COUNT
def intersectCountTable = "test_intersect_count"
sql """ DROP TABLE IF EXISTS ${intersectCountTable} """
sql """ create table if not exists ${intersectCountTable} (dt int (11),page varchar (10),user_id bitmap BITMAP_UNION ) DISTRIBUTED BY HASH(dt) BUCKETS 2 PROPERTIES("replication_num" = "1") """
sql """ create table if not exists ${intersectCountTable} (dt int (11),page varchar (10),insert_date date,user_id bitmap BITMAP_UNION ) DISTRIBUTED BY HASH(dt) BUCKETS 2 PROPERTIES("replication_num" = "1") """


sql """ insert into ${intersectCountTable} values(3,"110001", to_bitmap(1)); """
sql """ insert into ${intersectCountTable} values(3,"110001", to_bitmap(2)); """
sql """ insert into ${intersectCountTable} values(3,"110001", to_bitmap(3)); """
sql """ insert into ${intersectCountTable} values(3,"110001", to_bitmap(4)); """
sql """ insert into ${intersectCountTable} values(3,"110001", to_bitmap(5)); """
sql """ insert into ${intersectCountTable} values(4,"110001", to_bitmap(1)); """
sql """ insert into ${intersectCountTable} values(4,"110001", to_bitmap(2)); """
sql """ insert into ${intersectCountTable} values(4,"110001", to_bitmap(3)); """
sql """ insert into ${intersectCountTable} values(3,"110001", "2022-10-13", to_bitmap(1)); """
sql """ insert into ${intersectCountTable} values(3,"110001", "2022-10-13", to_bitmap(2)); """
sql """ insert into ${intersectCountTable} values(3,"110001", "2022-10-13", to_bitmap(3)); """
sql """ insert into ${intersectCountTable} values(3,"110001", "2022-10-13", to_bitmap(4)); """
sql """ insert into ${intersectCountTable} values(3,"110001", "2022-10-13", to_bitmap(5)); """
sql """ insert into ${intersectCountTable} values(4,"110001", "2022-10-14", to_bitmap(1)); """
sql """ insert into ${intersectCountTable} values(4,"110001", "2022-10-14", to_bitmap(2)); """
sql """ insert into ${intersectCountTable} values(4,"110001", "2022-10-14", to_bitmap(3)); """

qt_sql """ select dt,bitmap_to_string(user_id) from ${intersectCountTable} where dt in (3,4) order by dt desc; """
qt_sql """ select dt,insert_date,bitmap_to_string(user_id) from ${intersectCountTable} where dt in (3,4) order by dt desc; """
qt_sql """ select intersect_count(user_id,dt,3,4) from ${intersectCountTable}; """
qt_sql """ select intersect_count(user_id,insert_date,'2022-10-13','2022-10-14') from ${intersectCountTable}; """

// ARTHOGONAL_BITMAP_****
def arthogonalBitmapTable = "test_arthogonal_bitmap"
Expand Down

0 comments on commit 2ca88df

Please sign in to comment.