version:2.5
DDL:
CREATE TABLE IF NOT EXISTS aggregate_tbl (
uid int NOT NULL COMMENT "id of site",
age int not null,
pv int sum default "0"
)
DISTRIBUTED BY HASH(uid) BUCKETS 8
PROPERTIES (
"replication_num" = "1"
);
DML:
insert into aggregate_tbl values(1,18,2147483640),(1,20,2147483640)
test case:
# ok,pv=4294967280
select sum(pv),count(1) from aggregate_tbl
where uid=1
# ok, pv=4294967280
select sum(pv+0) from aggregate_tbl
where uid=1
# not ok,pv=-16
select sum(cast(pv as bigint)) from aggregate_tbl
where uid=1
首先建表时注意类型的范围当然是一个成熟的开发必备的,但是如果真有这种 cast
,现在的表现还是可能会造成使用者的迷惑,是否可以改善一下这里了?