|
我在idea中开发flink-sql代码,current_date在任务提交的那一刻,他的时间已经停止了,并不会随着时间的变化而改变,这也是我group by current_date,id这种计算结果插入到mysql永远都是累计的。因为current_date只要使用到,好像就已经成为常量了。我之前所有的数据累加的问题应该也是这个问题导致的。我枯了。,各位大神有没有好的方法解决。这是我的实现逻辑。
数据源层面--------------------------------------------
|insert into dwd_worktask_info
|select
| cccti.Id,
| cccti.WorkName,
| cccti.CustomerId,
| cccti.HandlerOrgId,
| ccctmd.LastHandlePersonId,
| ccctmd.LastDistributionTime,
| ccctmd.LastHandleOrgId
| currnet_date as As_Of_Date
| from cc_task_info cccti
|join cc_task_****_dis ccctmd on cccti.Id=TaskInfoId and ccctmd.IsDeleted=0 and ccctmd.CreateTime>cast(current_date as TimeStamp)
|where cccti.IsDeleted=0 and cccti.DistributionTime>cast(current_date as TimeStamp)
计算层面----------------------------------------------------------------------------------------------|insert into app_bs_drainage_place
|SELECT
| do.GrouporgName,
| du.Name,
| COUNT(DISTINCT dooi.Code) AS Total,
| md5(concat(do.GrouporgName,du.Name,cast(dwi.As_Of_Date as String))) as uuids,
| dwi.As_Of_Date as As_Of_Date
|FROM dw_od_order_info dooi
|INNER JOIN dwd_worktask_info dwi ON dwi.CustomerId = dooi.CustomerId AND dwi.HandlerPersonId = dooi.UserId and dwi.As_Of_Date=current_date
|INNER JOIN dim_cc_***** dmplr ON dmplr.MediaPlacementId = dwi.PlacementId
|INNER JOIN dim_*** dcml ON dmplr.LabelId = dcml.Id
|INNER JOIN dim_user_**** du ON dooi.UserId = du.Id
|INNER JOIN dim_org_**** do ON dooi.UserOrgId = do.Grouporgid
|WHERE dooi.OrderTime>cast(current_date as TIMESTAMP) and dooi.Status <> 60 AND dooi.Status <> 120 AND dooi.OrgType = 1
|GROUP BY dwi.As_Of_Date,do.GrouporgName,du.Name
|