@@ -99,8 +99,9 @@ func (s *MySQLStorage) StoreQuerySample(ctx context.Context, sample *QuerySample
9999 cell_a_used_new_engine, cell_b_used_new_engine,
100100 sampled_at,
101101 comparison_status,
102- match_within_tolerance
103- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
102+ match_within_tolerance,
103+ mismatch_cause
104+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
104105 `
105106
106107 // Convert empty span IDs to NULL for database storage
@@ -112,6 +113,12 @@ func (s *MySQLStorage) StoreQuerySample(ctx context.Context, sample *QuerySample
112113 cellBSpanID = sample .CellBSpanID
113114 }
114115
116+ // Prepare nullable mismatch_cause (NULL when empty)
117+ var mismatchCauseVal any
118+ if comparison .MismatchCause != "" {
119+ mismatchCauseVal = comparison .MismatchCause
120+ }
121+
115122 // Prepare nullable result storage metadata
116123 var cellAResultURI , cellBResultURI any
117124 var cellAResultSize , cellBResultSize any
@@ -181,6 +188,7 @@ func (s *MySQLStorage) StoreQuerySample(ctx context.Context, sample *QuerySample
181188 sample .SampledAt ,
182189 comparison .ComparisonStatus ,
183190 comparison .MatchWithinTolerance ,
191+ mismatchCauseVal ,
184192 )
185193
186194 return err
@@ -200,22 +208,29 @@ func (s *MySQLStorage) StoreComparisonResult(ctx context.Context, result *Compar
200208
201209 query := `
202210 INSERT INTO comparison_outcomes (
203- correlation_id, comparison_status, match_within_tolerance,
211+ correlation_id, comparison_status, match_within_tolerance, mismatch_cause,
204212 difference_details, performance_metrics,
205213 compared_at
206- ) VALUES (?, ?, ?, ?, ?, ?)
214+ ) VALUES (?, ?, ?, ?, ?, ?, ? )
207215 ON DUPLICATE KEY UPDATE
208216 comparison_status = VALUES(comparison_status),
209217 match_within_tolerance = VALUES(match_within_tolerance),
218+ mismatch_cause = VALUES(mismatch_cause),
210219 difference_details = VALUES(difference_details),
211220 performance_metrics = VALUES(performance_metrics),
212221 compared_at = VALUES(compared_at)
213222 `
214223
224+ var comparisonMismatchCause any
225+ if result .MismatchCause != "" {
226+ comparisonMismatchCause = result .MismatchCause
227+ }
228+
215229 _ , err = s .db .ExecContext (ctx , query ,
216230 result .CorrelationID ,
217231 result .ComparisonStatus ,
218232 result .MatchWithinTolerance ,
233+ comparisonMismatchCause ,
219234 differenceJSON ,
220235 perfMetricsJSON ,
221236 result .ComparedAt ,
@@ -255,7 +270,7 @@ func (s *MySQLStorage) GetSampledQueries(ctx context.Context, page, pageSize int
255270 cell_a_span_id, cell_b_span_id,
256271 cell_a_used_new_engine, cell_b_used_new_engine,
257272 sampled_at, created_at,
258- comparison_status, match_within_tolerance
273+ comparison_status, match_within_tolerance, mismatch_cause
259274 FROM sampled_queries
260275 ` + whereClause + `
261276 ORDER BY sampled_at DESC
@@ -303,7 +318,7 @@ func (s *MySQLStorage) GetSampledQueries(ctx context.Context, page, pageSize int
303318 & cellASpanID , & cellBSpanID ,
304319 & q .CellAUsedNewEngine , & q .CellBUsedNewEngine ,
305320 & q .SampledAt , & createdAt ,
306- & q .ComparisonStatus , & q .MatchWithinTolerance ,
321+ & q .ComparisonStatus , & q .MatchWithinTolerance , & q . MismatchCause ,
307322 )
308323 if err != nil {
309324 return nil , err
@@ -378,7 +393,7 @@ func (s *MySQLStorage) GetQueryByCorrelationID(ctx context.Context, correlationI
378393 cell_a_trace_id, cell_b_trace_id,
379394 cell_a_span_id, cell_b_span_id,
380395 cell_a_used_new_engine, cell_b_used_new_engine,
381- sampled_at, created_at, comparison_status, match_within_tolerance
396+ sampled_at, created_at, comparison_status, match_within_tolerance, mismatch_cause
382397 FROM sampled_queries
383398 WHERE correlation_id = ?
384399 `
@@ -405,7 +420,7 @@ func (s *MySQLStorage) GetQueryByCorrelationID(ctx context.Context, correlationI
405420 & q .CellATraceID , & q .CellBTraceID ,
406421 & cellASpanID , & cellBSpanID ,
407422 & q .CellAUsedNewEngine , & q .CellBUsedNewEngine ,
408- & q .SampledAt , & createdAt , & q .ComparisonStatus , & q .MatchWithinTolerance ,
423+ & q .SampledAt , & createdAt , & q .ComparisonStatus , & q .MatchWithinTolerance , & q . MismatchCause ,
409424 )
410425
411426 if err != nil {
0 commit comments