From c1eb436e9d467eeab2993bda097c15541e11dd5b Mon Sep 17 00:00:00 2001 From: kniewiadomski Date: Mon, 11 Jan 2021 15:13:52 +0100 Subject: [PATCH] added ability to compare files with different number of columns --- cmd/config.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/config.go b/cmd/config.go index 81996ac..d13e761 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -53,7 +53,22 @@ func NewContext( } if baseRecordCount != deltaRecordCount { - return nil, fmt.Errorf("base-file and delta-file columns count do not match") + if len(valueColumnPositions) > 0 { + var maxColumnPositions int = 0 + for _, value := range valueColumnPositions { + if maxColumnPositions < value { + maxColumnPositions = value + } + } + if baseRecordCount <= maxColumnPositions { + return nil, fmt.Errorf("base-file does not have column %v", maxColumnPositions) + } + if deltaRecordCount <= maxColumnPositions { + return nil, fmt.Errorf("delta-file does not have column %v", maxColumnPositions) + } + } else { + return nil, fmt.Errorf("base-file and delta-file columns count do not match and columns to selective compare not specified") + } } if len(ignoreValueColumnPositions) > 0 && len(valueColumnPositions) > 0 {