如图,查询数据集以及将这个数据集插入到表中查询后,数据有不一致的情况出现,这样并不符合预期。其中表模型为明细模型,参数也如图。有尝试过INSERT OVERWRITE () PARITION(*)和INSERT INTO,均失败。
241025更新[完整测试步骤]
1.SELECT 一个数据集
2.将这个数据集进行INSERT OVERWRITE写入,代码示例如下:
INSERT OVERWRITE TABLE ads.ads_marketing_shipping_channel_statistic_di PARTITION(*) SELECT t1.出库时间
,t1.渠道,t1.日出库量
,IFNULL(t1.月累计出库量
,'0') AS 月累计出库量
,IFNULL(t1.上年同期月出库量
,'0') AS 上年同期月出库量
,IFNULL(t1.月同比
,'0') AS 月同比
,IFNULL(t1.上年同期月出库量(整月)
,'0') AS 上年同期月出库量(整月)
,IFNULL(t1.月同比(整月)
,'0') AS 月同比(整月)
,IFNULL(t1.年累出库量
,'0') AS 年累出库量
,IFNULL(t1.上年同期年出库量
,'0') AS 上年同期年出库量
,IFNULL(t1.年同比
,'0') AS 年同比
,IFNULL(t1.上年同期年出库量(整月)
,'0') AS 上年同期年出库量(整月)
,IFNULL(t1.年同比(整月)
,'0') AS 年同比(整月)
FROM
()AS t1
3.datagrip打开该表和SELECT * 该表,发现结果和插入数据集数据不一致.建表语句如下:
CREATE TABLE IF NOT EXISTS ads.ads_marketing_shipping_channel_statistic_di (
out_time
DATE NULL COMMENT '出库时间',
own_channel
VARCHAR(100) NULL COMMENT '渠道',
out_nums
BIGINT NULL COMMENT '日出库量',
monthly_out_nums
BIGINT NULL COMMENT '月累出库量',
monthly_yoy_out_nums
BIGINT NULL COMMENT '上年同期月出库量',
monthly_yoy_ratio
VARCHAR(100) NULL COMMENT '月同比',
whole_monthly_yoy_out_nums
BIGINT NULL COMMENT '上年同期月出库量-整月',
whole_monthly_yoy_ratio
VARCHAR(100) NULL COMMENT '月同比-整月',
annual_out_nums
BIGINT NULL COMMENT '年累出库量',
annual_yoy_out_nums
BIGINT NULL COMMENT '上年同期年出库量',
annual_yoy_ratio
VARCHAR(100) NULL COMMENT '年同比',
whole_annual_yoy_out_nums
BIGINT NULL COMMENT '上年同期年出库量-整月',
whole_annual_yoy_ratio
VARCHAR(100) NULL COMMENT '年同比-整月'
) ENGINE=OLAP
DUPLICATE KEY(out_time
)
PARTITION BY RANGE(out_time
)
()
DISTRIBUTED BY HASH(own_channel
) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"storage_medium" = "ssd",
"storage_format" = "V2",
"light_schema_change" = "true",
"skip_write_index_on_load" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "pd",
"dynamic_partition.create_history_partition" = "true",
"dynamic_partition.history_partition_num" = "1000"
)