/// <inheritdoc cref="State{T}.Sum"/> public override FrequenciesAndNumRows Sum(FrequenciesAndNumRows other) { IEnumerable <string> columns = Frequencies.Schema().Fields .Select(field => field.Name) .Where(field => field != AnalyzersExt.COUNT_COL); IEnumerable <Column> projectionAfterMerge = columns .Select(col => Coalesce(Col($"this.{col}"), Col($"other.{col}")).As(col)) .Append( (AnalyzersExt.ZeroIfNull($"this.{AnalyzersExt.COUNT_COL}") + AnalyzersExt.ZeroIfNull($"other.{AnalyzersExt.COUNT_COL}")).As(AnalyzersExt.COUNT_COL)); Column joinCondition = columns.Aggregate(NullSafeEq(columns.First()), (previous, result) => previous.And(NullSafeEq(result))); DataFrame frequenciesSum = Frequencies .Alias("this") .Join(other.Frequencies.Alias("other"), joinCondition, "outer") .Select(projectionAfterMerge.ToArray()); return(new FrequenciesAndNumRows(frequenciesSum, NumRows + other.NumRows)); }