fix(api): 修复latest_op_ts无法记录
mysql的greatest函数,null永远是最大值
This commit is contained in:
@@ -250,7 +250,7 @@ public class SyncStateService {
|
||||
}
|
||||
|
||||
public void saveCompactionLatestOperationTime(Long flinkJobId, String alias, Long latestOperationTime) {
|
||||
Date operationDate = ObjectUtil.isNull(latestOperationTime) ? null : Date.from(Instant.ofEpochMilli(latestOperationTime));
|
||||
Date operationDate = latestOperationTime == 0 ? null : Date.from(Instant.ofEpochMilli(latestOperationTime));
|
||||
jdbcTemplate.update(
|
||||
SqlBuilder
|
||||
.insertInto(
|
||||
@@ -260,10 +260,18 @@ public class SyncStateService {
|
||||
)
|
||||
.values()
|
||||
.addValue(null, null)
|
||||
.onDuplicateKeyUpdateSetter(StrUtil.format("{} = GREATEST({}, ?)", TbAppHudiSyncState.COMPACTION_LATEST_OP_TS_O, TbAppHudiSyncState.COMPACTION_LATEST_OP_TS_O))
|
||||
.onDuplicateKeyUpdateSetter(
|
||||
StrUtil.format(
|
||||
"{} = if({} is null, ?, greatest({}, ?))",
|
||||
TbAppHudiSyncState.COMPACTION_LATEST_OP_TS_O,
|
||||
TbAppHudiSyncState.COMPACTION_LATEST_OP_TS_O,
|
||||
TbAppHudiSyncState.COMPACTION_LATEST_OP_TS_O
|
||||
)
|
||||
)
|
||||
.precompileSql(),
|
||||
syncStateId(flinkJobId, alias),
|
||||
operationDate,
|
||||
operationDate,
|
||||
operationDate
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user