Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 6, 2024
1 parent 436b840 commit af607e9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions flow/connectors/postgres/qvalue_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ func parseUUID(value interface{}) (qvalue.QValue, error) {
return nil, fmt.Errorf("invalid UUID string: %w", err)
}
return qvalue.QValueUUID{Val: id}, nil
case [16]byte:
return qvalue.QValueUUID{Val: uuid.UUID(v)}, nil
case uuid.UUID:
return qvalue.QValueUUID{Val: v}, nil
default:
Expand All @@ -267,6 +269,12 @@ func parseUUIDArray(value interface{}) (qvalue.QValue, error) {
uuids = append(uuids, id)
}
return qvalue.QValueArrayUUID{Val: uuids}, nil
case [][16]byte:
uuids := make([]uuid.UUID, 0, len(v))
for _, v := range v {
uuids = append(uuids, uuid.UUID(v))
}
return qvalue.QValueArrayUUID{Val: uuids}, nil
case []uuid.UUID:
return qvalue.QValueArrayUUID{Val: v}, nil
default:
Expand Down
18 changes: 18 additions & 0 deletions flow/model/qvalue/equals.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func Equals(qv QValue, other QValue) bool {
return compareTimeArrays(qvValue, otherValue)
case QValueArrayBoolean:
return compareBoolArrays(q.Val, otherValue)
case QValueArrayUUID:
return compareUuidArrays(q.Val, otherValue)
case QValueArrayString:
return compareArrayString(q.Val, otherValue)
default:
Expand Down Expand Up @@ -321,6 +323,22 @@ func compareBoolArrays(value1, value2 interface{}) bool {
return true
}

func compareUuidArrays(value1, value2 interface{}) bool {
array1, ok1 := value1.([]uuid.UUID)
array2, ok2 := value2.([]uuid.UUID)

if !ok1 || !ok2 || len(array1) != len(array2) {
return false
}

for i := range array1 {
if array1[i] != array2[i] {
return false
}
}
return true
}

func compareArrayString(value1, value2 interface{}) bool {
array1, ok1 := value1.([]string)
array2, ok2 := value2.([]string)
Expand Down
2 changes: 1 addition & 1 deletion flow/model/qvalue/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ var QValueKindToClickHouseTypeMap = map[QValueKind]string{
QValueKindArrayTimestampTZ: "Array(DateTime64(6))",
QValueKindArrayJSON: "String",
QValueKindArrayJSONB: "String",
QValueKindArrayUUID: "Array(String)",
QValueKindArrayUUID: "Array(UUID)",
}

func getClickHouseTypeForNumericColumn(ctx context.Context, env map[string]string, column *protos.FieldDescription) (string, error) {
Expand Down

0 comments on commit af607e9

Please sign in to comment.