feat(api): 对于需要记录最后时间的字段使用比较方式更新
This commit is contained in:
@@ -3,6 +3,7 @@ package com.lanyuanxiaoyao.service.api.service;
|
|||||||
import club.kingon.sql.builder.SqlBuilder;
|
import club.kingon.sql.builder.SqlBuilder;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.lanyuanxiaoyao.service.api.entity.HoodieCommitMetadata;
|
import com.lanyuanxiaoyao.service.api.entity.HoodieCommitMetadata;
|
||||||
import com.lanyuanxiaoyao.service.common.Constants;
|
import com.lanyuanxiaoyao.service.common.Constants;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -119,9 +120,18 @@ public class SyncStateService {
|
|||||||
)
|
)
|
||||||
.values()
|
.values()
|
||||||
.addValue(null, null)
|
.addValue(null, null)
|
||||||
.onDuplicateKeyUpdateColumn(TbAppHudiSyncState.SOURCE_PUBLISH_TIME_O)
|
.onDuplicateKeyUpdateSetter(
|
||||||
|
StrUtil.format(
|
||||||
|
"{} = if({} is null, ?, greatest({}, ?))",
|
||||||
|
TbAppHudiSyncState.SOURCE_PUBLISH_TIME_O,
|
||||||
|
TbAppHudiSyncState.SOURCE_PUBLISH_TIME_O,
|
||||||
|
TbAppHudiSyncState.SOURCE_PUBLISH_TIME_O
|
||||||
|
)
|
||||||
|
)
|
||||||
.precompileSql(),
|
.precompileSql(),
|
||||||
syncStateId(flinkJobId, alias),
|
syncStateId(flinkJobId, alias),
|
||||||
|
publishDate,
|
||||||
|
publishDate,
|
||||||
publishDate
|
publishDate
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -137,9 +147,18 @@ public class SyncStateService {
|
|||||||
)
|
)
|
||||||
.values()
|
.values()
|
||||||
.addValue(null, null)
|
.addValue(null, null)
|
||||||
.onDuplicateKeyUpdateColumn(TbAppHudiSyncState.SOURCE_RECEIVE_TIME_O)
|
.onDuplicateKeyUpdateSetter(
|
||||||
|
StrUtil.format(
|
||||||
|
"{} = if({} is null, ?, greatest({}, ?))",
|
||||||
|
TbAppHudiSyncState.SOURCE_RECEIVE_TIME_O,
|
||||||
|
TbAppHudiSyncState.SOURCE_RECEIVE_TIME_O,
|
||||||
|
TbAppHudiSyncState.SOURCE_RECEIVE_TIME_O
|
||||||
|
)
|
||||||
|
)
|
||||||
.precompileSql(),
|
.precompileSql(),
|
||||||
syncStateId(flinkJobId, alias),
|
syncStateId(flinkJobId, alias),
|
||||||
|
receiveDate,
|
||||||
|
receiveDate,
|
||||||
receiveDate
|
receiveDate
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -155,9 +174,18 @@ public class SyncStateService {
|
|||||||
)
|
)
|
||||||
.values()
|
.values()
|
||||||
.addValue(null, null)
|
.addValue(null, null)
|
||||||
.onDuplicateKeyUpdateColumn(TbAppHudiSyncState.SOURCE_OP_TIME_O)
|
.onDuplicateKeyUpdateSetter(
|
||||||
|
StrUtil.format(
|
||||||
|
"{} = if({} is null, ?, greatest({}, ?))",
|
||||||
|
TbAppHudiSyncState.SOURCE_OP_TIME_O,
|
||||||
|
TbAppHudiSyncState.SOURCE_OP_TIME_O,
|
||||||
|
TbAppHudiSyncState.SOURCE_OP_TIME_O
|
||||||
|
)
|
||||||
|
)
|
||||||
.precompileSql(),
|
.precompileSql(),
|
||||||
syncStateId(flinkJobId, alias),
|
syncStateId(flinkJobId, alias),
|
||||||
|
operationDate,
|
||||||
|
operationDate,
|
||||||
operationDate
|
operationDate
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -299,9 +327,18 @@ public class SyncStateService {
|
|||||||
)
|
)
|
||||||
.values()
|
.values()
|
||||||
.addValue(null, null)
|
.addValue(null, null)
|
||||||
.onDuplicateKeyUpdateColumn(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(),
|
.precompileSql(),
|
||||||
syncStateId(flinkJobId, alias),
|
syncStateId(flinkJobId, alias),
|
||||||
|
operationDate,
|
||||||
|
operationDate,
|
||||||
operationDate
|
operationDate
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user