CREATE TABLE ods_profile.test
(
id
largeint NULL COMMENT "主键id",
base_recharge_amount
decimal(38,20) NULL COMMENT "",
finish_time
datetime NULL COMMENT "完成时间"
) ENGINE=OLAP
UNIQUE KEY(id
)
COMMENT 'xx'
DISTRIBUTED BY HASH(id
) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"min_load_replica_num" = "-1",
"is_being_synced" = "false",
"storage_medium" = "hdd",
"storage_format" = "V2",
"inverted_index_storage_format" = "V2",
"enable_unique_key_merge_on_write" = "true",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000",
"group_commit_data_bytes" = "134217728",
"enable_mow_light_delete" = "false"
);
insert into ods_profile.test
select 1, 2.23,'2025-01-01 00:00:00';
select * from ods_profile.test
;
select
id ,
map_agg(id, map('base_recharge_amount', base_recharge_amount, 'finish_time', cast(date_format(finish_time, '%Y-%m-%d %H:%i:%s') as string))) as map11,
map_agg(id, map('base_recharge_amount', base_recharge_amount, 'finish_time', finish_time)) as map22,
map_agg(id, map('base_recharge_amount', cast(base_recharge_amount as string), 'finish_time', finish_time)) as map33
from (
select
id,
finish_time,
base_recharge_amount
from ods_profile.test
) a
group by id;
三种写法,map里面的value的date类型的字段值,有一种变成了decimal的写法,非常长的数字。
感觉map里面前一个value的类型对后一个value的类型有影响。
另外一个demo:
map_agg(event_day, map('water_base', water_base, 'water_reward_base', water_reward_base, 'total_win_loss_base', total_win_loss_base, 'card_count', card_count, 'game_seconds', game_seconds)) as card_map
当里面计算的value是这种,全是decimal或者long类型的时候,没有发现这种类型问题。但是用date的时候突然看到不对了。
doris-3.0.4-rc02-39f9074cec,存算一体,单fe,单be。测试环境的。
使用BigDecimal的时候也遇到了数据的问题,会导致精度问题,感觉初步方案是将奇奇怪怪的类型全部cast as string,这样可以减少很多类型带来的数据问题