@@ -18,10 +18,13 @@ import (
1818 "context"
1919 "fmt"
2020 "log/slog"
21+ "math"
2122 "strconv"
2223 "time"
2324)
2425
26+ const floatEqualityEpsilon = 1e-9
27+
2528// DataQualityCheckType represents the type of data quality check.
2629type DataQualityCheckType string
2730
@@ -138,8 +141,9 @@ func (d DbqDataValidatorImpl) RunCheck(ctx context.Context, adapter DbqDataSourc
138141 result .Pass = true
139142 }
140143 } else {
141- // Unknown schema check type, default to pass
142- result .Pass = true
144+ // Unknown schema check type, fail-safe
145+ result .Pass = false
146+ result .Error = fmt .Sprintf ("unknown schema check type for expression: %s" , check .Expression )
143147 }
144148 } else {
145149 // Regular checks use the existing validation logic
@@ -186,9 +190,9 @@ func (d DbqDataValidatorImpl) validateResult(queryResult interface{}, parsedChec
186190 case "!=" , "<>" :
187191 return d .validateNotEqual (actualValue , parsedCheck .ThresholdValue )
188192 default :
189- d .logger .Warn ("Unknown operator, defaulting to true " ,
193+ d .logger .Error ("Unknown operator, failing check " ,
190194 "operator" , parsedCheck .Operator )
191- return true
195+ return false
192196 }
193197}
194198
@@ -297,7 +301,7 @@ func (d DbqDataValidatorImpl) validateLessThanOrEqual(actualValue float64, thres
297301 return actualValue <= threshold
298302}
299303
300- // validateEqual checks if actual == threshold
304+ // validateEqual checks if actual == threshold (with epsilon tolerance for float comparison)
301305func (d DbqDataValidatorImpl ) validateEqual (actualValue float64 , thresholdValue interface {}) bool {
302306 threshold , err := d .convertToFloat64 (thresholdValue )
303307 if err != nil {
@@ -306,10 +310,10 @@ func (d DbqDataValidatorImpl) validateEqual(actualValue float64, thresholdValue
306310 "error" , err )
307311 return false
308312 }
309- return actualValue == threshold
313+ return math . Abs ( actualValue - threshold ) < floatEqualityEpsilon
310314}
311315
312- // validateNotEqual checks if actual != threshold
316+ // validateNotEqual checks if actual != threshold (with epsilon tolerance for float comparison)
313317func (d DbqDataValidatorImpl ) validateNotEqual (actualValue float64 , thresholdValue interface {}) bool {
314318 threshold , err := d .convertToFloat64 (thresholdValue )
315319 if err != nil {
@@ -318,7 +322,7 @@ func (d DbqDataValidatorImpl) validateNotEqual(actualValue float64, thresholdVal
318322 "error" , err )
319323 return false
320324 }
321- return actualValue != threshold
325+ return math . Abs ( actualValue - threshold ) >= floatEqualityEpsilon
322326}
323327
324328// convertToFloat64 converts various types to float64
0 commit comments