From e4f35205f6c4d854889f69bae02f42e8aee36104 Mon Sep 17 00:00:00 2001 From: nhsmw Date: Tue, 18 Feb 2025 18:19:52 +0800 Subject: [PATCH] test: fix canal_json_storage test (#1014) ref pingcap/ticdc#442 --- pkg/sink/codec/canal/encoder.go | 16 ++++++++++------ .../conf/diff_config.toml | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/sink/codec/canal/encoder.go b/pkg/sink/codec/canal/encoder.go index 99df824a1..b716e8fd6 100644 --- a/pkg/sink/codec/canal/encoder.go +++ b/pkg/sink/codec/canal/encoder.go @@ -601,14 +601,17 @@ type JSONTxnEventEncoder struct { txnCommitTs uint64 txnSchema *string txnTable *string + + columnSelector columnselector.Selector } // NewJSONTxnEventEncoderBuilder creates a new JSONTxnEventEncoder func NewJSONTxnEventEncoderBuilder(config *common.Config) common.TxnEventEncoder { return &JSONTxnEventEncoder{ - valueBuf: &bytes.Buffer{}, - terminator: []byte(config.Terminator), - config: config, + valueBuf: &bytes.Buffer{}, + terminator: []byte(config.Terminator), + columnSelector: columnselector.NewDefaultColumnSelector(), + config: config, } } @@ -620,9 +623,10 @@ func (j *JSONTxnEventEncoder) AppendTxnEvent(event *commonEvent.DMLEvent) error break } value, err := newJSONMessageForDML(&commonEvent.RowEvent{ - TableInfo: event.TableInfo, - CommitTs: event.CommitTs, - Event: row, + TableInfo: event.TableInfo, + CommitTs: event.CommitTs, + Event: row, + ColumnSelector: j.columnSelector, }, j.config, false, "") if err != nil { return err diff --git a/tests/integration_tests/canal_json_storage_partition_table/conf/diff_config.toml b/tests/integration_tests/canal_json_storage_partition_table/conf/diff_config.toml index 24e98abed..26bdd1515 100644 --- a/tests/integration_tests/canal_json_storage_partition_table/conf/diff_config.toml +++ b/tests/integration_tests/canal_json_storage_partition_table/conf/diff_config.toml @@ -7,7 +7,7 @@ export-fix-sql = true check-struct-only = false [task] - output-dir = "/tmp/tidb_cdc_test/partition_table/sync_diff/output" + output-dir = "/tmp/tidb_cdc_test/canal_json_storage_partition_table/sync_diff/output" source-instances = ["mysql1"]