Skip to content

[cdc] Support computed columns when sync_database#5816

Merged
yuzelin merged 2 commits intoapache:masterfrom
JackeyLee007:db-sync-eval
Jul 1, 2025
Merged

[cdc] Support computed columns when sync_database#5816
yuzelin merged 2 commits intoapache:masterfrom
JackeyLee007:db-sync-eval

Conversation

@JackeyLee007
Copy link
Contributor

Purpose

To use computed columns when sync_database. The computed columns could refer to existed fields or other computed columns.

Tests

  1. Test computed columns when sync_database, with e2e case
    org.apache.paimon.flink.action.cdc.kafka.KafkaCanalSyncDatabaseActionITCase#testExpressionNow
    , by adding a new filed: pt=date_format(etl_update_time,yyyy-MM-dd).

  2. Test the sortting of computed columns, with case:
    org.apache.paimon.flink.action.cdc.ComputedColumnUtilsTest

API and Format

Documentation

/** Returns an instance of an unresolved {@link CdcSchema}. */
public CdcSchema build() {
return new CdcSchema(columns, primaryKeys, comment);
List<DataField> fields = columns.values().stream().collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List<DataField> fields = new ArrayList<>(columns.values())

/** Test for ComputedColumnUtils. */
public class ComputedColumnUtilsTest {
@Test
public void test() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testSortComputedColumns

@yuzelin yuzelin merged commit ef9e214 into apache:master Jul 1, 2025
22 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants