Skip to content

Commit

Permalink
chore: minor formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Nov 6, 2023
1 parent 6583364 commit b3d9edb
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 51 deletions.
2 changes: 1 addition & 1 deletion warehouse/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ func (g *GRPC) validateObjectStorage(ctx context.Context, request validateObject
return fmt.Errorf("unable to create temp file: \n%w", err)
}
defer func() {
os.Remove(f.Name())
_ = os.Remove(f.Name())
}()

err = fileManager.Download(
Expand Down
2 changes: 1 addition & 1 deletion warehouse/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (cl *Client) sqlQuery(statement string) (result warehouseutils.QueryResult,
if errors.Is(err, sql.ErrNoRows) {
return result, nil
}
defer rows.Close()
defer func() { _ = rows.Close() }()

result.Columns, err = rows.Columns()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion warehouse/client/warehouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestWarehouse(t *testing.T) {

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "bad request")
_, _ = fmt.Fprintf(w, "bad request")
}))
t.Cleanup(ts.Close)

Expand Down
2 changes: 1 addition & 1 deletion warehouse/integrations/azure-synapse/azure_synapse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ func TestAzureSynapse_ProcessColumnValue(t *testing.T) {
name: "valid float",
data: "1.01",
dataType: model.FloatDataType,
expectedValue: float64(1.01),
expectedValue: 1.01,
},
{
name: "invalid boolean",
Expand Down
9 changes: 5 additions & 4 deletions warehouse/integrations/datalake/schema-repository/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schemarepository

import (
"context"
"errors"
"fmt"
"net/url"
"regexp"
Expand Down Expand Up @@ -77,7 +78,7 @@ func (gl *GlueSchemaRepository) FetchSchema(ctx context.Context, warehouse model

getTablesOutput, err = gl.GlueClient.GetTablesWithContext(ctx, getTablesInput)
if err != nil {
if _, ok := err.(*glue.EntityNotFoundException); ok {
if errors.Is(err, &glue.EntityNotFoundException{}) {
gl.logger.Debugf("FetchSchema: database %s not found in glue. returning empty schema", warehouse.Namespace)
err = nil
}
Expand Down Expand Up @@ -121,7 +122,7 @@ func (gl *GlueSchemaRepository) CreateSchema(ctx context.Context) (err error) {
Name: &gl.Namespace,
},
})
if _, ok := err.(*glue.AlreadyExistsException); ok {
if errors.Is(err, &glue.EntityNotFoundException{}) {
gl.logger.Infof("Skipping database creation : database %s already exists", gl.Namespace)
err = nil
}
Expand Down Expand Up @@ -150,7 +151,7 @@ func (gl *GlueSchemaRepository) CreateTable(ctx context.Context, tableName strin

_, err = gl.GlueClient.CreateTableWithContext(ctx, &input)
if err != nil {
_, ok := err.(*glue.AlreadyExistsException)
ok := errors.Is(err, &glue.EntityNotFoundException{})
if ok {
err = nil
}
Expand Down Expand Up @@ -309,7 +310,7 @@ func (gl *GlueSchemaRepository) RefreshPartitions(ctx context.Context, tableName
})

if err != nil {
if _, ok := err.(*glue.EntityNotFoundException); !ok {
if !errors.Is(err, &glue.EntityNotFoundException{}) {
return fmt.Errorf("get partition: %w", err)
}

Expand Down
2 changes: 1 addition & 1 deletion warehouse/integrations/mssql/mssql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ func TestMSSQL_ProcessColumnValue(t *testing.T) {
name: "valid float",
data: "1.01",
dataType: model.FloatDataType,
expectedValue: float64(1.01),
expectedValue: 1.01,
},
{
name: "invalid boolean",
Expand Down
4 changes: 2 additions & 2 deletions warehouse/internal/loadfiles/mock_loadfile_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (m *mockLoadFilesRepo) Insert(_ context.Context, loadFiles []model.LoadFile
return nil
}

func (m *mockLoadFilesRepo) DeleteByStagingFiles(ctx context.Context, stagingFileIDs []int64) error {
func (m *mockLoadFilesRepo) DeleteByStagingFiles(_ context.Context, stagingFileIDs []int64) error {
store := make([]model.LoadFile, 0)
for _, loadFile := range m.store {
if !slices.Contains(stagingFileIDs, loadFile.StagingFileID) {
Expand All @@ -35,7 +35,7 @@ func (m *mockLoadFilesRepo) DeleteByStagingFiles(ctx context.Context, stagingFil
return nil
}

func (m *mockLoadFilesRepo) GetByStagingFiles(ctx context.Context, stagingFileIDs []int64) ([]model.LoadFile, error) {
func (m *mockLoadFilesRepo) GetByStagingFiles(_ context.Context, stagingFileIDs []int64) ([]model.LoadFile, error) {
var loadFiles []model.LoadFile
for _, loadFile := range m.store {
if slices.Contains(stagingFileIDs, loadFile.StagingFileID) {
Expand Down
4 changes: 2 additions & 2 deletions warehouse/internal/loadfiles/mock_stagefile_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type mockStageFilesRepo struct {
store map[int64]model.StagingFile
}

func (m *mockStageFilesRepo) SetStatuses(ctx context.Context, ids []int64, status string) (err error) {
func (m *mockStageFilesRepo) SetStatuses(_ context.Context, ids []int64, status string) (err error) {
if m.store == nil {
m.store = make(map[int64]model.StagingFile)
}
Expand All @@ -26,7 +26,7 @@ func (m *mockStageFilesRepo) SetStatuses(ctx context.Context, ids []int64, statu
return nil
}

func (m *mockStageFilesRepo) SetErrorStatus(ctx context.Context, stagingFileID int64, stageFileErr error) error {
func (m *mockStageFilesRepo) SetErrorStatus(_ context.Context, stagingFileID int64, stageFileErr error) error {
m.store[stagingFileID] = model.StagingFile{
ID: stagingFileID,
Status: warehouseutils.StagingFileFailedState,
Expand Down
14 changes: 7 additions & 7 deletions warehouse/internal/repo/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -1314,19 +1314,19 @@ func (u *Uploads) RetryFailedBatches(
return r.RowsAffected()
}

func (uploads *Uploads) WithTx(ctx context.Context, f func(tx *sqlmiddleware.Tx) error) error {
return (*repo)(uploads).WithTx(ctx, f)
func (u *Uploads) WithTx(ctx context.Context, f func(tx *sqlmiddleware.Tx) error) error {
return (*repo)(u).WithTx(ctx, f)
}

func (uploads *Uploads) Update(ctx context.Context, id int64, fields []UpdateKeyValue) error {
return uploads.update(ctx, uploads.db.ExecContext, id, fields)
func (u *Uploads) Update(ctx context.Context, id int64, fields []UpdateKeyValue) error {
return u.update(ctx, u.db.ExecContext, id, fields)
}

func (uploads *Uploads) UpdateWithTx(ctx context.Context, tx *sqlmiddleware.Tx, id int64, fields []UpdateKeyValue) error {
return uploads.update(ctx, tx.ExecContext, id, fields)
func (u *Uploads) UpdateWithTx(ctx context.Context, tx *sqlmiddleware.Tx, id int64, fields []UpdateKeyValue) error {
return u.update(ctx, tx.ExecContext, id, fields)
}

func (uploads *Uploads) update(
func (u *Uploads) update(
ctx context.Context,
exec func(context.Context, string, ...interface{}) (sql.Result, error),
id int64,
Expand Down
11 changes: 0 additions & 11 deletions warehouse/router/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,6 @@ type pendingTableUploadsRepo interface {
PendingTableUploads(ctx context.Context, namespace string, uploadID int64, destID string) ([]model.PendingTableUpload, error)
}

const (
UploadStatusField = "status"
UploadStartLoadFileIDField = "start_load_file_id"
UploadEndLoadFileIDField = "end_load_file_id"
UploadUpdatedAtField = "updated_at"
UploadTimingsField = "timings"
UploadSchemaField = "schema"
UploadLastExecAtField = "last_exec_at"
UploadInProgress = "in_progress"
)

var (
alwaysMarkExported = []string{whutils.DiscardsTable}
warehousesToAlwaysRegenerateAllLoadFilesOnResume = []string{whutils.SNOWFLAKE, whutils.BQ}
Expand Down
20 changes: 0 additions & 20 deletions warehouse/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,26 +740,6 @@ type Tag struct {
Value string
}

func NewTimerStat(name string, extraTags ...Tag) stats.Measurement {
tags := stats.Tags{
"module": WAREHOUSE,
}
for _, extraTag := range extraTags {
tags[extraTag.Name] = extraTag.Value
}
return stats.Default.NewTaggedStat(name, stats.TimerType, tags)
}

func NewCounterStat(name string, extraTags ...Tag) stats.Measurement {
tags := stats.Tags{
"module": WAREHOUSE,
}
for _, extraTag := range extraTags {
tags[extraTag.Name] = extraTag.Value
}
return stats.Default.NewTaggedStat(name, stats.CountType, tags)
}

func WHCounterStat(name string, warehouse *model.Warehouse, extraTags ...Tag) stats.Measurement {
tags := stats.Tags{
"module": WAREHOUSE,
Expand Down

0 comments on commit b3d9edb

Please sign in to comment.