Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 22edcf2

Browse files
authored
Log column name when validation failed (#1507)
It is hard to determine which part of the payload (or even ingesting service) is ingesting incorrect data based on just: ``` Invalid value type for column of type Int64: string, value: <SOME_RANDOM_STRING> ``` Putting column name would make tracing the source of the problem so much easier.
1 parent 697ce8c commit 22edcf2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

platform/ingest/ingest_validator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func validateNumericRange(columnType string, value interface{}) (isValid bool) {
8888
}
8989
}
9090

91-
func validateNumericType(columnType string, incomingValueType string, value interface{}) (isValid bool) {
91+
func validateNumericType(columnName, columnType string, incomingValueType string, value interface{}) (isValid bool) {
9292
if isFloatingPointType(columnType) && isNumericType(incomingValueType) {
9393
return true
9494
}
@@ -101,19 +101,19 @@ func validateNumericType(columnType string, incomingValueType string, value inte
101101
if valueAsStr, ok := value.(string); ok {
102102
return util.IsFloat(valueAsStr)
103103
} else {
104-
logger.Error().Msgf("Invalid value type for column of type %s: %T, value: %v", columnType, value, value)
104+
logger.Error().Msgf("Invalid value type for column [%s] of type %s: %T, value: %v", columnName, columnType, value, value)
105105
}
106106
}
107107
if isIntegerType(columnType) && incomingValueType == "String" {
108108
if valueAsStr, ok := value.(string); ok && util.IsInt(valueAsStr) {
109109
valueAsInt, err := util.ToInt64(valueAsStr)
110110
if err != nil {
111-
logger.Error().Msgf("Failed to convert value to int: %v", valueAsStr)
111+
logger.Error().Msgf("Failed to convert value to int: %v when processing data for column [%s]", valueAsStr, columnName)
112112
return false
113113
}
114114
return validateNumericRange(columnType, valueAsInt)
115115
} else {
116-
logger.Error().Msgf("Invalid value type for column of type %s: %T, value: %v", columnType, value, value)
116+
logger.Error().Msgf("Invalid value type for column [%s] of type %s: %T, value: %v", columnName, columnType, value, value)
117117
}
118118
}
119119

@@ -131,7 +131,7 @@ func validateValueAgainstType(fieldName string, value interface{}, columnType da
131131
columnTypeName := removeLowCardinality(columnType.Name)
132132

133133
if isNumericType(columnTypeName) {
134-
if incomingValueType, isBaseType := incomingValueType.(database_common.BaseType); isBaseType && validateNumericType(columnTypeName, incomingValueType.Name, value) {
134+
if incomingValueType, isBaseType := incomingValueType.(database_common.BaseType); isBaseType && validateNumericType(fieldName, columnTypeName, incomingValueType.Name, value) {
135135
// Numeric types match!
136136
return true
137137
}

0 commit comments

Comments
 (0)