feat: add validation feature for row count comparison
Add a validate command that compares row counts between source and target tables after a migration.
This commit is contained in:
@@ -76,6 +76,7 @@ func (ex *GenericExtractor) ProcessPartition(
|
||||
|
||||
batchRows := make([]models.UnknownRowValues, 0, batchSize)
|
||||
var rowsRead int64 = 0
|
||||
var lastRow models.UnknownRowValues
|
||||
|
||||
for rows.Next() {
|
||||
rowValues := make([]any, len(columns))
|
||||
@@ -90,7 +91,7 @@ func (ex *GenericExtractor) ProcessPartition(
|
||||
return rowsRead, err
|
||||
}
|
||||
|
||||
if err := flush(ctx, &partition, batchSize, batchRows, chBatchesOut); err != nil {
|
||||
if err := flush(ctx, batchSize, batchRows, chBatchesOut); err != nil {
|
||||
return rowsRead, err
|
||||
}
|
||||
|
||||
@@ -98,11 +99,12 @@ func (ex *GenericExtractor) ProcessPartition(
|
||||
return rowsRead, errorFromLastPartitionRow(lastRow, indexPrimaryKey, partition, err)
|
||||
}
|
||||
rowsRead++
|
||||
lastRow = rowValues
|
||||
|
||||
batchRows = append(batchRows, rowValues)
|
||||
if len(batchRows) >= batchSize {
|
||||
// logrus.Debugf("Batch size reached, flushing batch with %v rows (rowsRead=%v)", len(batchRows), rowsRead)
|
||||
if err := flush(ctx, &partition, batchSize, batchRows, chBatchesOut); err != nil {
|
||||
if err := flush(ctx, batchSize, batchRows, chBatchesOut); err != nil {
|
||||
// logrus.Warnf("Error flushing rows: %v", err)
|
||||
return rowsRead, err
|
||||
}
|
||||
@@ -110,9 +112,16 @@ func (ex *GenericExtractor) ProcessPartition(
|
||||
}
|
||||
}
|
||||
|
||||
if err := flush(ctx, &partition, batchSize, batchRows, chBatchesOut); err != nil {
|
||||
if err := flush(ctx, batchSize, batchRows, chBatchesOut); err != nil {
|
||||
return rowsRead, err
|
||||
}
|
||||
|
||||
return rowsRead, rows.Err()
|
||||
if err := rows.Err(); err != nil {
|
||||
if lastRow != nil {
|
||||
return rowsRead, errorFromLastPartitionRow(lastRow, indexPrimaryKey, partition, err)
|
||||
}
|
||||
return rowsRead, err
|
||||
}
|
||||
|
||||
return rowsRead, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user