From f9f9951b060c96363c25a5084b83d2f052744409 Mon Sep 17 00:00:00 2001 From: Herman Schaaf Date: Thu, 18 May 2023 20:40:45 +0100 Subject: [PATCH 1/2] Test null writes in append --- plugins/destination/plugin_testing_write_append.go | 10 +++++----- schema/testdata.go | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/destination/plugin_testing_write_append.go b/plugins/destination/plugin_testing_write_append.go index 20d4def2d8..5d056ba0db 100644 --- a/plugins/destination/plugin_testing_write_append.go +++ b/plugins/destination/plugin_testing_write_append.go @@ -35,7 +35,7 @@ func (s *PluginTestSuite) destinationPluginTestWriteAppend(ctx context.Context, opts := schema.GenTestDataOptions{ SourceName: sourceName, SyncTime: syncTime, - MaxRows: 1, + MaxRows: 2, } record1 := schema.GenTestData(table, opts)[0] if err := p.writeOne(ctx, specSource, syncTime, record1); err != nil { @@ -59,9 +59,9 @@ func (s *PluginTestSuite) destinationPluginTestWriteAppend(ctx context.Context, } sortRecordsBySyncTime(table, resourcesRead) - expectedResource := 2 + expectedResource := 3 if s.tests.SkipSecondAppend { - expectedResource = 1 + expectedResource = 2 } if len(resourcesRead) != expectedResource { @@ -74,8 +74,8 @@ func (s *PluginTestSuite) destinationPluginTestWriteAppend(ctx context.Context, } if !s.tests.SkipSecondAppend { - if !array.RecordApproxEqual(record2, resourcesRead[1]) { - diff := RecordDiff(record2, resourcesRead[1]) + if !array.RecordApproxEqual(record2, resourcesRead[2]) { + diff := RecordDiff(record2, resourcesRead[2]) return fmt.Errorf("second expected resource diff: %s", diff) } } diff --git a/schema/testdata.go b/schema/testdata.go index dd35532c6d..57e98c2b9b 100644 --- a/schema/testdata.go +++ b/schema/testdata.go @@ -329,8 +329,7 @@ func GenTestData(table *Table, opts GenTestDataOptions) []arrow.Record { if nullRow && !c.NotNull && !c.PrimaryKey && c.Name != CqSourceNameColumn.Name && c.Name != CqSyncTimeColumn.Name && - c.Name != CqIDColumn.Name && - c.Name != CqParentIDColumn.Name { + c.Name != CqIDColumn.Name { bldr.Field(i).AppendNull() continue } From c15daeba38507cc94fb9e8e544518e7a724ade31 Mon Sep 17 00:00:00 2001 From: Herman Schaaf Date: Fri, 19 May 2023 08:50:22 +0100 Subject: [PATCH 2/2] Fix --- .../destination/plugin_testing_write_append.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/destination/plugin_testing_write_append.go b/plugins/destination/plugin_testing_write_append.go index 5d056ba0db..578d20c35f 100644 --- a/plugins/destination/plugin_testing_write_append.go +++ b/plugins/destination/plugin_testing_write_append.go @@ -37,9 +37,9 @@ func (s *PluginTestSuite) destinationPluginTestWriteAppend(ctx context.Context, SyncTime: syncTime, MaxRows: 2, } - record1 := schema.GenTestData(table, opts)[0] - if err := p.writeOne(ctx, specSource, syncTime, record1); err != nil { - return fmt.Errorf("failed to write one second time: %w", err) + record1 := schema.GenTestData(table, opts) + if err := p.writeAll(ctx, specSource, syncTime, record1); err != nil { + return fmt.Errorf("failed to write record first time: %w", err) } secondSyncTime := syncTime.Add(10 * time.Second).UTC() @@ -68,9 +68,13 @@ func (s *PluginTestSuite) destinationPluginTestWriteAppend(ctx context.Context, return fmt.Errorf("expected %d resources, got %d", expectedResource, len(resourcesRead)) } - if !array.RecordApproxEqual(record1, resourcesRead[0]) { - diff := RecordDiff(record1, resourcesRead[0]) - return fmt.Errorf("first expected resource diff: %s", diff) + if !array.RecordApproxEqual(record1[0], resourcesRead[0]) { + diff := RecordDiff(record1[0], resourcesRead[0]) + return fmt.Errorf("first expected resource diff at row 0: %s", diff) + } + if !array.RecordApproxEqual(record1[1], resourcesRead[1]) { + diff := RecordDiff(record1[1], resourcesRead[1]) + return fmt.Errorf("first expected resource diff at row 1: %s", diff) } if !s.tests.SkipSecondAppend {