Skip to content

Commit

Permalink
Clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jan 20, 2025
1 parent faecbe0 commit 6d47497
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clients/snowflake/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *Store) PrepareTemporaryTable(ctx context.Context, tableData *optimizati
// This is because [PURGE = TRUE] will only delete the staging files upon a successful COPY INTO.
// We also only need to do this for non-temp tables because these staging files will linger, since we create a new temporary table per attempt.
if !createTempTable {
if _, deleteErr := s.ExecContext(ctx, s.dialect().BuildRemoveFilesFromStage(tempTableID.FullyQualifiedName(), "")); deleteErr != nil {
if _, deleteErr := s.ExecContext(ctx, s.dialect().BuildRemoveFilesFromStage(addPrefixToTableName(tempTableID, "%"), "")); deleteErr != nil {
slog.Warn("Failed to remove all files from stage", slog.Any("deleteErr", deleteErr))
}
}
Expand Down
7 changes: 7 additions & 0 deletions clients/snowflake/staging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import (
"github.com/artie-labs/transfer/lib/typing/columns"
)

func (s *SnowflakeTestSuite) TestBuildRemoveFilesFromStage() {
table := dialect.NewTableIdentifier("db", "schema", "table")

query := s.stageStore.dialect().BuildRemoveFilesFromStage(addPrefixToTableName(table, "%"), "")
assert.Equal(s.T(), `REMOVE @db.schema."%table"`, query)
}

func (s *SnowflakeTestSuite) TestReplaceExceededValues() {
// String + OptionalStringPrecision not set + equal to max LOB length:
assert.Equal(s.T(), strings.Repeat("a", 16777216), replaceExceededValues(strings.Repeat("a", 16777216), typing.String))
Expand Down

0 comments on commit 6d47497

Please sign in to comment.