@@ -31,11 +31,12 @@ import (
3131var ErrIteratorDone = errors .New ("snapshot complete" )
3232
3333type Config struct {
34- Position opencdc.Position
35- Tables []string
36- TableKeys map [string ]string
37- TXSnapshotID string
38- FetchSize int
34+ Position opencdc.Position
35+ Tables []string
36+ TableKeys map [string ]string
37+ TXSnapshotID string
38+ FetchSize int
39+ WithAvroSchema bool
3940}
4041
4142type Iterator struct {
@@ -122,8 +123,10 @@ func (i *Iterator) buildRecord(d FetchData) opencdc.Record {
122123 metadata ["postgres.table" ] = d .Table
123124
124125 rec := sdk .Util .Source .NewRecordSnapshot (pos , metadata , d .Key , d .Payload )
125- cschema .AttachKeySchemaToRecord (rec , d .KeySchema )
126- cschema .AttachPayloadSchemaToRecord (rec , d .PayloadSchema )
126+ if i .conf .WithAvroSchema {
127+ cschema .AttachKeySchemaToRecord (rec , d .KeySchema )
128+ cschema .AttachPayloadSchemaToRecord (rec , d .PayloadSchema )
129+ }
127130
128131 return rec
129132}
@@ -135,11 +138,12 @@ func (i *Iterator) initFetchers(ctx context.Context) error {
135138
136139 for j , t := range i .conf .Tables {
137140 w := NewFetchWorker (i .db , i .data , FetchConfig {
138- Table : t ,
139- Key : i .conf .TableKeys [t ],
140- TXSnapshotID : i .conf .TXSnapshotID ,
141- Position : i .lastPosition ,
142- FetchSize : i .conf .FetchSize ,
141+ Table : t ,
142+ Key : i .conf .TableKeys [t ],
143+ TXSnapshotID : i .conf .TXSnapshotID ,
144+ Position : i .lastPosition ,
145+ FetchSize : i .conf .FetchSize ,
146+ WithAvroSchema : i .conf .WithAvroSchema ,
143147 })
144148
145149 if err := w .Validate (ctx ); err != nil {
0 commit comments