From 4185d1913f623d6c17f0bb5e2f0a54d76bc195ca Mon Sep 17 00:00:00 2001 From: Yevgeny Pats Date: Tue, 16 May 2023 16:24:43 +0300 Subject: [PATCH] Revert "feat(test): Test writing to a child table (#878)" This reverts commit d4154fb4e2bc703d2974afa4e7dd9c2c774940f9. --- internal/memdb/memdb.go | 2 +- plugins/destination/plugin_testing_overwrite.go | 7 ++++--- .../plugin_testing_overwrite_delete_stale.go | 12 +++++++----- plugins/destination/plugin_testing_write_append.go | 9 +++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/internal/memdb/memdb.go b/internal/memdb/memdb.go index 99e7bae401..9c6bbb74d1 100644 --- a/internal/memdb/memdb.go +++ b/internal/memdb/memdb.go @@ -95,7 +95,7 @@ func (c *client) overwrite(table *schema.Table, data arrow.Record) { } func (c *client) Migrate(_ context.Context, tables schema.Tables) error { - for _, table := range tables.FlattenTables() { + for _, table := range tables { tableName := table.Name memTable := c.memoryDB[tableName] if memTable == nil { diff --git a/plugins/destination/plugin_testing_overwrite.go b/plugins/destination/plugin_testing_overwrite.go index c244aad782..29c1bdd7b5 100644 --- a/plugins/destination/plugin_testing_overwrite.go +++ b/plugins/destination/plugin_testing_overwrite.go @@ -20,10 +20,11 @@ func (*PluginTestSuite) destinationPluginTestWriteOverwrite(ctx context.Context, } tableName := fmt.Sprintf("cq_%s_%d", spec.Name, time.Now().Unix()) table := schema.TestTable(tableName, testSourceOptions...) - parent := schema.TestTable(tableName+"_parent", testSourceOptions...) - parent.Relations = schema.Tables{table} syncTime := time.Now().UTC().Round(1 * time.Second) - if err := p.Migrate(ctx, schema.Tables{parent}); err != nil { + tables := schema.Tables{ + table, + } + if err := p.Migrate(ctx, tables); err != nil { return fmt.Errorf("failed to migrate tables: %w", err) } diff --git a/plugins/destination/plugin_testing_overwrite_delete_stale.go b/plugins/destination/plugin_testing_overwrite_delete_stale.go index 0bd5493f3a..06d92761fa 100644 --- a/plugins/destination/plugin_testing_overwrite_delete_stale.go +++ b/plugins/destination/plugin_testing_overwrite_delete_stale.go @@ -22,10 +22,12 @@ func (*PluginTestSuite) destinationPluginTestWriteOverwriteDeleteStale(ctx conte table := schema.TestTable(tableName, testSourceOptions...) incTable := schema.TestTable(tableName+"_incremental", testSourceOptions...) incTable.IsIncremental = true - parent := schema.TestTable(tableName+"_parent", testSourceOptions...) - parent.Relations = schema.Tables{table, incTable} syncTime := time.Now().UTC().Round(1 * time.Second) - if err := p.Migrate(ctx, schema.Tables{parent}); err != nil { + tables := schema.Tables{ + table, + incTable, + } + if err := p.Migrate(ctx, tables); err != nil { return fmt.Errorf("failed to migrate tables: %w", err) } @@ -106,7 +108,7 @@ func (*PluginTestSuite) destinationPluginTestWriteOverwriteDeleteStale(ctx conte return fmt.Errorf("after overwrite expected first resource to be different. diff: %s", diff) } - resourcesRead, err = p.readAll(ctx, table, sourceName) + resourcesRead, err = p.readAll(ctx, tables[0], sourceName) if err != nil { return fmt.Errorf("failed to read all second time: %w", err) } @@ -122,7 +124,7 @@ func (*PluginTestSuite) destinationPluginTestWriteOverwriteDeleteStale(ctx conte // we expect the incremental table to still have 2 resources, because delete-stale should // not apply there - resourcesRead, err = p.readAll(ctx, incTable, sourceName) + resourcesRead, err = p.readAll(ctx, tables[1], sourceName) if err != nil { return fmt.Errorf("failed to read all from incremental table: %w", err) } diff --git a/plugins/destination/plugin_testing_write_append.go b/plugins/destination/plugin_testing_write_append.go index 3202fc8797..20d4def2d8 100644 --- a/plugins/destination/plugin_testing_write_append.go +++ b/plugins/destination/plugin_testing_write_append.go @@ -19,10 +19,11 @@ func (s *PluginTestSuite) destinationPluginTestWriteAppend(ctx context.Context, } tableName := fmt.Sprintf("cq_%s_%d", spec.Name, time.Now().Unix()) table := schema.TestTable(tableName, testSourceOptions...) - parent := schema.TestTable(tableName+"_parent", testSourceOptions...) - parent.Relations = schema.Tables{table} syncTime := time.Now().UTC().Round(1 * time.Second) - if err := p.Migrate(ctx, schema.Tables{parent}); err != nil { + tables := schema.Tables{ + table, + } + if err := p.Migrate(ctx, tables); err != nil { return fmt.Errorf("failed to migrate tables: %w", err) } @@ -52,7 +53,7 @@ func (s *PluginTestSuite) destinationPluginTestWriteAppend(ctx context.Context, } } - resourcesRead, err := p.readAll(ctx, table, sourceName) + resourcesRead, err := p.readAll(ctx, tables[0], sourceName) if err != nil { return fmt.Errorf("failed to read all second time: %w", err) }