[cdc] Support computed expression of now#5138
Merged
yuzelin merged 8 commits intoapache:masterfrom Mar 15, 2025
Merged
Conversation
Contributor
Author
|
@JingsongLi Have a code review again, please. I adpated the code according to your comments in the previous PR 5086.
|
JingsongLi
reviewed
Mar 3, 2025
| return now; | ||
| } | ||
|
|
||
| return insertOnly ? null : now; |
Contributor
There was a problem hiding this comment.
Copy from #5086 :
So if a new input update the record, the create_time will become null?
071cf0b to
1ca6efb
Compare
added 2 commits
March 14, 2025 21:07
yuzelin
reviewed
Mar 15, 2025
|
|
||
| @Override | ||
| public DataType outputType() { | ||
| return DataTypes.TIMESTAMP(); |
yuzelin
reviewed
Mar 15, 2025
|
|
||
| @Override | ||
| public String eval(String input) { | ||
| return java.sql.Timestamp.valueOf(LocalDateTime.now()).toString(); |
Contributor
There was a problem hiding this comment.
Use DateTimeUtils.formatLocalDateTime
| protected void beforeBuildingSourceSink() throws Exception { | ||
| computedColumns = | ||
| buildComputedColumns( | ||
| computedColumnArgs, Collections.singletonList(SpecialFields.VALUE_KIND)); |
Contributor
There was a problem hiding this comment.
Move to withComputedColumnArgs
| } | ||
| return Objects.toString(entry.getValue()); | ||
| })); | ||
|
|
Comment on lines
196
to
197
| LOG.warn("actual: " + sortedActual); | ||
| LOG.warn("expected: " + sortedExpected); |
| cnt++; | ||
| } | ||
|
|
||
| LOG.info("actual: field: " + field.name() + " " + field.type()); |
| new AliyunRecordParser(TypeMapping.defaultMapping(), Collections.emptyList()); | ||
| new AliyunRecordParser(TypeMapping.defaultMapping(), computedColumns); | ||
| for (String json : insertList) { | ||
| // 将json解析为JsonNode对象 |
| Assert.assertTrue(createTime.matches(dateTimeRegex)); | ||
| Assert.assertTrue(updateTime.matches(dateTimeRegex)); | ||
|
|
||
| log.info("createTime: {}, updateTime: {}", createTime, updateTime); |
| new AliyunRecordParser(TypeMapping.defaultMapping(), Collections.emptyList()); | ||
| new AliyunRecordParser(TypeMapping.defaultMapping(), computedColumns); | ||
| for (String json : updateList) { | ||
| // 将json解析为JsonNode对象 |
| new AliyunRecordParser(TypeMapping.defaultMapping(), Collections.emptyList()); | ||
| new AliyunRecordParser(TypeMapping.defaultMapping(), computedColumns); | ||
| for (String json : deleteList) { | ||
| // 将json解析为JsonNode对象 |
|
|
||
| /** IT cases for {@link KafkaSyncDatabaseAction}. */ | ||
| public class KafkaCanalSyncDatabaseActionITCase extends KafkaActionITCaseBase { | ||
| private static final Logger LOG = |
Contributor
|
+1 |
danzhewuju
pushed a commit
to danzhewuju/paimon
that referenced
this pull request
Mar 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: close #5068
Support special audition computed columns, especially for cdc sync database
Tests
org.apache.paimon.flink.action.cdc.kafka.KafkaCanalSyncDatabaseActionITCase#testAuditTime
API and Format
Documentation