From 63673e01fce504bc9ce8641faf3bcf368ad7f4d6 Mon Sep 17 00:00:00 2001 From: Jon Seymour Date: Sat, 9 Apr 2016 19:32:57 +1000 Subject: [PATCH] PR #444: Relax join.as() validations to tolerate missing and duplicate prefixes Signed-off-by: Jon Seymour --- pipeline/join.go | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pipeline/join.go b/pipeline/join.go index 4022546ab7..54d8eec5d6 100644 --- a/pipeline/join.go +++ b/pipeline/join.go @@ -133,29 +133,18 @@ func (j *JoinNode) On(dims ...string) *JoinNode { // Validate that the as() specification is consistent with the number of join arms. func (j *JoinNode) Validate() error { - if len(j.Names) == 0 { - return fmt.Errorf("a call to join.as() is required to specify the output stream prefixes.") - } - if len(j.Names) != len(j.Parents()) { + if len(j.Names) > len(j.Parents()) { return fmt.Errorf("number of prefixes specified by join.as() must match the number of joined streams") + } else if len(j.Names) < len(j.Parents()) { + tmp := make([]string, len(j.Parents())) + copy(tmp, j.Names) + j.Names = tmp } - for _, name := range j.Names { - if len(name) == 0 { - return fmt.Errorf("must provide a prefix name for the join node, see .as() property method") - } if strings.ContainsRune(name, '.') { return fmt.Errorf("cannot use name %s as field prefix, it contains a '.' character", name) } } - names := make(map[string]bool, len(j.Names)) - for _, name := range j.Names { - if names[name] { - return fmt.Errorf("cannot use the same prefix name see .as() property method") - } - names[name] = true - } - return nil }