Repository navigation
fix: update table schema local repository - #6255
Merged
achettyiitr merged 2 commits intoAug 20, 2025
Merged
Conversation
achettyiitr
requested review from
RanjeetMishra,
shekhar-rudder and
vyeshwanth
August 20, 2025 04:58
shekhar-rudder
approved these changes
Aug 20, 2025
achettyiitr
commented
Aug 20, 2025
Comment on lines
+21
to
+185
| t.Run("Create table", func(t *testing.T) { | ||
| testCases := []struct { | ||
| name string | ||
| mockError error | ||
| localSchema model.Schema | ||
| wantError error | ||
| }{ | ||
| { | ||
| name: "success", | ||
| localSchema: model.Schema{}, | ||
| }, | ||
| { | ||
| name: "table already exists", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| }, | ||
| }, | ||
| wantError: fmt.Errorf("failed to create table: table %s already exists", "test_table"), | ||
| }, | ||
| wantError: fmt.Errorf("failed to create table: table %s already exists", "test_table"), | ||
| }, | ||
| { | ||
| name: "error updating local schema", | ||
| mockError: fmt.Errorf("error updating local schema"), | ||
| wantError: fmt.Errorf("error updating local schema"), | ||
| localSchema: model.Schema{}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| warehouse := model.Warehouse{} | ||
| uploader := newMockUploader(t, tc.mockError, tc.localSchema) | ||
|
|
||
| s, err := schemarepository.NewLocalSchemaRepository(warehouse, uploader) | ||
| require.NoError(t, err) | ||
|
|
||
| ctx := context.Background() | ||
|
|
||
| err = s.CreateTable(ctx, "test_table", model.TableSchema{ | ||
| "test_column_2": "test_type_2", | ||
| }) | ||
| if tc.wantError != nil { | ||
| require.EqualError(t, err, tc.wantError.Error()) | ||
| } else { | ||
| { | ||
| name: "error updating local schema", | ||
| mockError: fmt.Errorf("error updating local schema"), | ||
| wantError: fmt.Errorf("error updating local schema"), | ||
| localSchema: model.Schema{}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| warehouse := model.Warehouse{} | ||
| uploader := newMockUploader(t, tc.mockError, tc.localSchema) | ||
|
|
||
| s, err := schemarepository.NewLocalSchemaRepository(warehouse, uploader) | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestLocalSchemaRepository_AddColumns(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| mockError error | ||
| localSchema model.Schema | ||
| wantError error | ||
| }{ | ||
| { | ||
| name: "success", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| ctx := context.Background() | ||
|
|
||
| err = s.CreateTable(ctx, "test_table", model.TableSchema{ | ||
| "test_column_2": "test_type_2", | ||
| }) | ||
| if tc.wantError != nil { | ||
| require.EqualError(t, err, tc.wantError.Error()) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("Add columns", func(t *testing.T) { | ||
| testCases := []struct { | ||
| name string | ||
| mockError error | ||
| localSchema model.Schema | ||
| wantError error | ||
| }{ | ||
| { | ||
| name: "success", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: "table does not exists", | ||
| wantError: fmt.Errorf("failed to add column: table %s does not exist", "test_table"), | ||
| }, | ||
| { | ||
| name: "error updating local schema", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| { | ||
| name: "table does not exists", | ||
| wantError: fmt.Errorf("failed to add column: table %s does not exist", "test_table"), | ||
| }, | ||
| { | ||
| name: "error updating local schema", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| }, | ||
| }, | ||
| mockError: fmt.Errorf("error updating local schema"), | ||
| wantError: fmt.Errorf("error updating local schema"), | ||
| }, | ||
| mockError: fmt.Errorf("error updating local schema"), | ||
| wantError: fmt.Errorf("error updating local schema"), | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| } | ||
|
|
||
| warehouse := model.Warehouse{} | ||
| uploader := newMockUploader(t, tc.mockError, tc.localSchema) | ||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| warehouse := model.Warehouse{} | ||
| uploader := newMockUploader(t, tc.mockError, tc.localSchema) | ||
|
|
||
| s, err := schemarepository.NewLocalSchemaRepository(warehouse, uploader) | ||
| require.NoError(t, err) | ||
| s, err := schemarepository.NewLocalSchemaRepository(warehouse, uploader) | ||
| require.NoError(t, err) | ||
|
|
||
| ctx := context.Background() | ||
| ctx := context.Background() | ||
|
|
||
| err = s.AddColumns(ctx, "test_table", []warehouseutils.ColumnInfo{ | ||
| { | ||
| Name: "test_column_2", | ||
| Type: "test_type_2", | ||
| }, | ||
| err = s.AddColumns(ctx, "test_table", []warehouseutils.ColumnInfo{ | ||
| { | ||
| Name: "test_column_2", | ||
| Type: "test_type_2", | ||
| }, | ||
| }) | ||
| if tc.wantError != nil { | ||
| require.EqualError(t, err, tc.wantError.Error()) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| if tc.wantError != nil { | ||
| require.EqualError(t, err, tc.wantError.Error()) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| func TestLocalSchemaRepository_AlterColumn(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| mockError error | ||
| localSchema model.Schema | ||
| wantError error | ||
| }{ | ||
| { | ||
| name: "success", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| t.Run("Alter columns", func(t *testing.T) { | ||
| testCases := []struct { | ||
| name string | ||
| mockError error | ||
| localSchema model.Schema | ||
| wantError error | ||
| }{ | ||
| { | ||
| name: "success", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: "table does not exists", | ||
| wantError: fmt.Errorf("failed to add column: table %s does not exist", "test_table"), | ||
| }, | ||
| { | ||
| name: "column does not exists", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_2": "test_type_2", | ||
| { | ||
| name: "table does not exists", | ||
| wantError: fmt.Errorf("failed to add column: table %s does not exist", "test_table"), | ||
| }, | ||
| { | ||
| name: "column does not exists", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_2": "test_type_2", | ||
| }, | ||
| }, | ||
| wantError: fmt.Errorf("failed to alter column: column %s does not exist in table %s", "test_column_1", "test_table"), | ||
| }, | ||
| wantError: fmt.Errorf("failed to alter column: column %s does not exist in table %s", "test_column_1", "test_table"), | ||
| }, | ||
| { | ||
| name: "error updating local schema", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| { | ||
| name: "error updating local schema", | ||
| localSchema: model.Schema{ | ||
| "test_table": { | ||
| "test_column_1": "test_type_1", | ||
| }, | ||
| }, | ||
| mockError: fmt.Errorf("error updating local schema"), | ||
| wantError: fmt.Errorf("error updating local schema"), | ||
| }, | ||
| mockError: fmt.Errorf("error updating local schema"), | ||
| wantError: fmt.Errorf("error updating local schema"), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| warehouse := model.Warehouse{} | ||
| uploader := newMockUploader(t, tc.mockError, tc.localSchema) | ||
|
|
||
| s, err := schemarepository.NewLocalSchemaRepository(warehouse, uploader) | ||
| require.NoError(t, err) | ||
|
|
||
| ctx := context.Background() | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| _, err = s.AlterColumn(ctx, "test_table", "test_column_1", "test_type_2") | ||
| if tc.wantError != nil { | ||
| require.EqualError(t, err, tc.wantError.Error()) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| }) |
Member
Author
There was a problem hiding this comment.
Didn't make any changes to existing tests. Just move these into a single one.
RanjeetMishra
approved these changes
Aug 20, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/1.57.x #6255 +/- ##
==================================================
- Coverage 77.03% 76.90% -0.14%
==================================================
Files 521 521
Lines 70905 70759 -146
==================================================
- Hits 54624 54417 -207
- Misses 13387 13464 +77
+ Partials 2894 2878 -16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merged
achettyiitr
pushed a commit
that referenced
this pull request
Aug 20, 2025
🤖 I have created a release *beep* *boop* --- ## [1.57.1](v1.57.0...v1.57.1) (2025-08-20) ### Bug Fixes * update table schema local repository ([#6255](#6255)) ([ddce7e4](ddce7e4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
achettyiitr
added a commit
that referenced
this pull request
Aug 20, 2025
# Description Syncing patch release v1.57.1 to main branch **↓↓ Please review and edit commit overrides before merging ↓↓** BEGIN_COMMIT_OVERRIDE fix: update table schema local repository (#6255) END_COMMIT_OVERRIDE --------- Co-authored-by: Akash Chetty <[email protected]>
This was referenced Aug 25, 2025
shekhar-rudder
added a commit
that referenced
this pull request
Aug 26, 2025
# Description Syncing patch release v1.57.3 to main branch **↓↓ Please review and edit commit overrides before merging ↓↓** BEGIN_COMMIT_OVERRIDE fix: update table schema local repository (#6255) fix: use source-id for getting cached schemas (#6268) chore: add alert for stuck snowpipe pipeline (#6271) END_COMMIT_OVERRIDE --------- Co-authored-by: Akash Chetty <[email protected]> Co-authored-by: shekhar-rudder <[email protected]> Co-authored-by: Shashank Shekhar <[email protected]>
This was referenced Sep 1, 2025
Merged
itsmihir
pushed a commit
that referenced
this pull request
Sep 1, 2025
🤖 I have created a release *beep* *boop* --- ## [1.58.0-rc.1](v1.57.0...v1.58.0-rc.1) (2025-09-01) ### Features * implement error normalizer with similarity detection for reporting ([#6248](#6248)) ([b4653d3](b4653d3)) * **router:** delivery throttler ([#6225](#6225)) ([f55c7a8](f55c7a8)) ### Bug Fixes * cron tracker query causing master restarts ([#6252](#6252)) ([51437b9](51437b9)) * snowpipe events getting duplicated if status API fails ([#6211](#6211)) ([#6244](#6244)) ([8d6838d](8d6838d)) * transformation metrics count amplification ([#6258](#6258)) ([fded7b3](fded7b3)) * update table schema local repository ([#6255](#6255)) ([2ec9a9f](2ec9a9f)) * update table schema local repository ([#6255](#6255)) ([4446e5b](4446e5b)) * use source-id for getting cached schemas ([#6268](#6268)) ([2ec9a9f](2ec9a9f)) * use source-id for getting cached schemas ([#6268](#6268)) ([90e4191](90e4191)) * warehouse migrations from master only ([#6282](#6282)) ([2309507](2309507)) ### Miscellaneous * add alert for stuck snowpipe pipeline ([#6271](#6271)) ([2ec9a9f](2ec9a9f)) * add context information on ut http error logs ([#6278](#6278)) ([424f22c](424f22c)) * bump amannn/action-semantic-pull-request from 5 to 6 ([#6237](#6237)) ([41c1548](41c1548)) * bump the go-deps group with 15 updates ([#6247](#6247)) ([8d6838d](8d6838d)) * bump the go-deps group with 3 updates ([#6254](#6254)) ([02a0263](02a0263)) * cleanup for schema snapshoting ([#6257](#6257)) ([4f3a68f](4f3a68f)) * remove flaky GooglePubSub retry configuration tests ([#6260](#6260)) ([6c48784](6c48784)) * remove null handling of upload id in load files ([#6241](#6241)) ([8d6838d](8d6838d)) * remove unused network code ([#6266](#6266)) ([f7cbc94](f7cbc94)) * **router:** rename endpointLabel to endpointPath ([#6279](#6279)) ([c933525](c933525)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
itsmihir
pushed a commit
that referenced
this pull request
Sep 2, 2025
🤖 I have created a release *beep* *boop* --- ## [1.58.0-rc.2](v1.57.0...v1.58.0-rc.2) (2025-09-02) ### Features * implement error normalizer with similarity detection for reporting ([#6248](#6248)) ([b4653d3](b4653d3)) * **router:** delivery throttler ([#6225](#6225)) ([f55c7a8](f55c7a8)) ### Bug Fixes * cron tracker query causing master restarts ([#6252](#6252)) ([51437b9](51437b9)) * snowpipe events getting duplicated if status API fails ([#6211](#6211)) ([#6244](#6244)) ([8d6838d](8d6838d)) * transformation metrics count amplification ([#6258](#6258)) ([fded7b3](fded7b3)) * update table schema local repository ([#6255](#6255)) ([2ec9a9f](2ec9a9f)) * update table schema local repository ([#6255](#6255)) ([4446e5b](4446e5b)) * use getStringifiedSampleEvent for consistent sample event handling ([#6290](#6290)) ([526975c](526975c)) * use source-id for getting cached schemas ([#6268](#6268)) ([2ec9a9f](2ec9a9f)) * use source-id for getting cached schemas ([#6268](#6268)) ([90e4191](90e4191)) * warehouse migrations from master only ([#6282](#6282)) ([2309507](2309507)) ### Miscellaneous * add alert for stuck snowpipe pipeline ([#6271](#6271)) ([2ec9a9f](2ec9a9f)) * add context information on ut http error logs ([#6278](#6278)) ([424f22c](424f22c)) * bump amannn/action-semantic-pull-request from 5 to 6 ([#6237](#6237)) ([41c1548](41c1548)) * bump the go-deps group with 15 updates ([#6247](#6247)) ([8d6838d](8d6838d)) * bump the go-deps group with 3 updates ([#6254](#6254)) ([02a0263](02a0263)) * cleanup for schema snapshoting ([#6257](#6257)) ([4f3a68f](4f3a68f)) * remove flaky GooglePubSub retry configuration tests ([#6260](#6260)) ([6c48784](6c48784)) * remove null handling of upload id in load files ([#6241](#6241)) ([8d6838d](8d6838d)) * remove unused network code ([#6266](#6266)) ([f7cbc94](f7cbc94)) * **router:** rename endpointLabel to endpointPath ([#6279](#6279)) ([c933525](c933525)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
itsmihir
pushed a commit
that referenced
this pull request
Sep 2, 2025
🤖 I have created a release *beep* *boop* --- ## [1.58.0](v1.57.0...v1.58.0) (2025-09-02) ### Features * implement error normalizer with similarity detection for reporting ([#6248](#6248)) ([b4653d3](b4653d3)) * **router:** delivery throttler ([#6225](#6225)) ([f55c7a8](f55c7a8)) ### Bug Fixes * cron tracker query causing master restarts ([#6252](#6252)) ([51437b9](51437b9)) * snowpipe events getting duplicated if status API fails ([#6211](#6211)) ([#6244](#6244)) ([8d6838d](8d6838d)) * transformation metrics count amplification ([#6258](#6258)) ([fded7b3](fded7b3)) * update table schema local repository ([#6255](#6255)) ([2ec9a9f](2ec9a9f)) * update table schema local repository ([#6255](#6255)) ([4446e5b](4446e5b)) * use getStringifiedSampleEvent for consistent sample event handling ([#6290](#6290)) ([526975c](526975c)) * use source-id for getting cached schemas ([#6268](#6268)) ([2ec9a9f](2ec9a9f)) * use source-id for getting cached schemas ([#6268](#6268)) ([90e4191](90e4191)) * warehouse migrations from master only ([#6282](#6282)) ([2309507](2309507)) ### Miscellaneous * add alert for stuck snowpipe pipeline ([#6271](#6271)) ([2ec9a9f](2ec9a9f)) * add context information on ut http error logs ([#6278](#6278)) ([424f22c](424f22c)) * bump amannn/action-semantic-pull-request from 5 to 6 ([#6237](#6237)) ([41c1548](41c1548)) * bump the go-deps group with 15 updates ([#6247](#6247)) ([8d6838d](8d6838d)) * bump the go-deps group with 3 updates ([#6254](#6254)) ([02a0263](02a0263)) * cleanup for schema snapshoting ([#6257](#6257)) ([4f3a68f](4f3a68f)) * remove flaky GooglePubSub retry configuration tests ([#6260](#6260)) ([6c48784](6c48784)) * remove null handling of upload id in load files ([#6241](#6241)) ([8d6838d](8d6838d)) * remove unused network code ([#6266](#6266)) ([f7cbc94](f7cbc94)) * **router:** rename endpointLabel to endpointPath ([#6279](#6279)) ([c933525](c933525)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Linear Ticket
Security