Skip to content

Commit f1ef1c9

Browse files
committed
Added virtualtimestamps field to cdc description
1 parent e27fd65 commit f1ef1c9

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Added virtualtimestamps field to cdc description
2+
13
## v3.99.10
24
* Returned legacy behaviour for interpret as `time.Time` YDB types `Date`, `Datetime` and `Timestamp`
35

table/options/models.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -562,18 +562,20 @@ func (unit *TimeToLiveUnit) ToYDB() Ydb_Table.ValueSinceUnixEpochModeSettings_Un
562562
}
563563

564564
type ChangefeedDescription struct {
565-
Name string
566-
Mode ChangefeedMode
567-
Format ChangefeedFormat
568-
State ChangefeedState
565+
Name string
566+
Mode ChangefeedMode
567+
Format ChangefeedFormat
568+
State ChangefeedState
569+
VirtualTimestamp bool
569570
}
570571

571572
func NewChangefeedDescription(proto *Ydb_Table.ChangefeedDescription) ChangefeedDescription {
572573
return ChangefeedDescription{
573-
Name: proto.GetName(),
574-
Mode: ChangefeedMode(proto.GetMode()),
575-
Format: ChangefeedFormat(proto.GetFormat()),
576-
State: ChangefeedState(proto.GetState()),
574+
Name: proto.GetName(),
575+
Mode: ChangefeedMode(proto.GetMode()),
576+
Format: ChangefeedFormat(proto.GetFormat()),
577+
State: ChangefeedState(proto.GetState()),
578+
VirtualTimestamp: proto.GetVirtualTimestamps(),
577579
}
578580
}
579581

tests/integration/table_create_table_description_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,34 @@ func TestCreateTableDescription(sourceTest *testing.T) {
167167
})
168168
}
169169
}
170+
171+
func TestTableDescriptionWithCDC(t *testing.T) {
172+
scope := newScope(t)
173+
escapedTablePath := "`" + scope.TablePath() + "`"
174+
err := scope.Driver().Query().Exec(scope.Ctx, "ALTER TABLE "+escapedTablePath+`
175+
ADD CHANGEFEED test WITH (
176+
MODE='NEW_AND_OLD_IMAGES',
177+
FORMAT='JSON',
178+
VIRTUAL_TIMESTAMPS = TRUE
179+
)`)
180+
scope.Require.NoError(err)
181+
182+
var description options.Description
183+
err = scope.Driver().Table().Do(scope.Ctx, func(ctx context.Context, s table.Session) error {
184+
desc, err := s.DescribeTable(ctx, scope.TablePath())
185+
if err == nil {
186+
description = desc
187+
}
188+
return err
189+
})
190+
191+
scope.Require.NoError(err)
192+
expectedCDC := options.ChangefeedDescription{
193+
Name: "test",
194+
Mode: options.ChangefeedModeNewAndOldImages,
195+
Format: options.ChangefeedFormatJSON,
196+
State: options.ChangefeedStateEnabled,
197+
VirtualTimestamp: true,
198+
}
199+
scope.Require.Equal([]options.ChangefeedDescription{expectedCDC}, description.Changefeeds)
200+
}

0 commit comments

Comments
 (0)