Skip to content

Commit

Permalink
disable more rules, remove unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 17, 2023
1 parent 8757bff commit 84f84d3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 31 deletions.
5 changes: 5 additions & 0 deletions flow/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ linters:
enable-all: true
disable:
- funlen
- gocognit
- godox
linters-settings:
lll:
line-length: 120
tab-width: 4
revive:
rules:
- name: if-return
disabled: true
2 changes: 1 addition & 1 deletion flow/concurrency/bound_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type BoundSelector struct {
ferrors []error
}

func NewBoundSelector(limit int, total int, ctx workflow.Context) *BoundSelector {
func NewBoundSelector(limit int, ctx workflow.Context) *BoundSelector {
return &BoundSelector{
ctx: ctx,
limit: limit,
Expand Down
2 changes: 0 additions & 2 deletions flow/connectors/snowflake/qrep_avro_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func (s *SnowflakeAvroSyncMethod) SyncQRepRecords(
s.connector.logger.Info("sync function called and schema acquired", partitionLog)

err = s.addMissingColumns(
config.FlowJobName,
schema,
dstTableSchema,
dstTableName,
Expand Down Expand Up @@ -152,7 +151,6 @@ func (s *SnowflakeAvroSyncMethod) SyncQRepRecords(
}

func (s *SnowflakeAvroSyncMethod) addMissingColumns(
flowJobName string,
schema *model.QRecordSchema,
dstTableSchema []*sql.ColumnType,
dstTableName string,
Expand Down
2 changes: 1 addition & 1 deletion flow/model/conversion_avro.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func GetAvroSchemaDefinition(
nullableFields := make(map[string]struct{})

for _, qField := range qRecordSchema.Fields {
avroType, err := qvalue.GetAvroSchemaFromQValueKind(qField.Type, qField.Nullable)
avroType, err := qvalue.GetAvroSchemaFromQValueKind(qField.Type)
if err != nil {
return nil, err
}
Expand Down
44 changes: 20 additions & 24 deletions flow/model/qvalue/avro_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,38 @@ type QValueKindAvroSchema struct {
//
// For example, QValueKindInt64 would return an AvroLogicalSchema of "long". Unsupported QValueKinds
// will return an error.
//
// The function currently does not support the following QValueKinds:
// - QValueKindBit
//
// Please note that for QValueKindNumeric and QValueKindETime, RespectNull is always
// set to false, regardless of the nullable value passed in.
func GetAvroSchemaFromQValueKind(kind QValueKind, nullable bool) (*QValueKindAvroSchema, error) {
func GetAvroSchemaFromQValueKind(kind QValueKind) (QValueKindAvroSchema, error) {
switch kind {
case QValueKindString, QValueKindUUID:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "string",
}, nil
case QValueKindGeometry, QValueKindGeography, QValueKindPoint:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "string",
}, nil
case QValueKindInt16, QValueKindInt32, QValueKindInt64:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "long",
}, nil
case QValueKindFloat32:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "float",
}, nil
case QValueKindFloat64:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "double",
}, nil
case QValueKindBoolean:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "boolean",
}, nil
case QValueKindBytes, QValueKindBit:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "bytes",
}, nil
case QValueKindNumeric:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]interface{}{
"type": "bytes",
"logicalType": "decimal",
Expand All @@ -69,60 +63,62 @@ func GetAvroSchemaFromQValueKind(kind QValueKind, nullable bool) (*QValueKindAvr
},
}, nil
case QValueKindTime, QValueKindTimeTZ, QValueKindDate, QValueKindTimestamp, QValueKindTimestampTZ:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]string{
"type": "string",
},
}, nil
case QValueKindHStore, QValueKindJSON, QValueKindStruct:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]interface{}{
"type": "string",
"values": "string",
},
}, nil
case QValueKindArrayFloat32:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]interface{}{
"type": "array",
"items": "float",
},
}, nil
case QValueKindArrayFloat64:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]interface{}{
"type": "array",
"items": "double",
},
}, nil
case QValueKindArrayInt32:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]interface{}{
"type": "array",
"items": "int",
},
}, nil
case QValueKindArrayInt64:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]interface{}{
"type": "array",
"items": "long",
},
}, nil
case QValueKindArrayString:
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: map[string]interface{}{
"type": "array",
"items": "string",
},
}, nil
case QValueKindInvalid:
// lets attempt to do invalid as a string
return &QValueKindAvroSchema{
return QValueKindAvroSchema{
AvroLogicalSchema: "string",
}, nil
default:
return nil, fmt.Errorf("unsupported QValueKind type: %s", kind)
return QValueKindAvroSchema{
AvroLogicalSchema: nil,
}, fmt.Errorf("unsupported QValueKind type: %s", kind)
}
}

Expand Down
2 changes: 1 addition & 1 deletion flow/model/qvalue/qvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func compareStruct(value1, value2 interface{}) bool {
return true
}

func compareJSON(value1, value2 interface{}) bool {
func compareJSON(_, _ interface{}) bool {
// TODO (kaushik): fix for tests
return true
}
Expand Down
3 changes: 1 addition & 2 deletions flow/workflows/snapshot_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ func (s *SnapshotFlowExecution) cloneTables(
slog.Info(fmt.Sprintf("cloning tables for slot name %s and snapshotName %s",
slotInfo.SlotName, slotInfo.SnapshotName))

numTables := len(s.config.TableMappings)
boundSelector := concurrency.NewBoundSelector(maxParallelClones, numTables, ctx)
boundSelector := concurrency.NewBoundSelector(maxParallelClones, ctx)

for _, v := range s.config.TableMappings {
source := v.SourceTableIdentifier
Expand Down

0 comments on commit 84f84d3

Please sign in to comment.