public override IList <string> GetColumnTypes() { var colTypes = new List <string>(); var input1 = InputDict[Inputs[0]]; var input1ColTypes = input1.GetColumnTypes(); for (var i = 0; i < GroupByColumnIndexes.Count; i++) { GroupByFunction groupByFunction = GroupByFunction.Date; if (i < GroupByFunctions.Count && GroupByFunctions[i].HasValue) { groupByFunction = GroupByFunctions[i].Value; } var colIndex = GroupByColumnIndexes[i]; if (colIndex < input1ColTypes.Count) { var colType = GetGroupByType(input1ColTypes[colIndex], groupByFunction); colTypes.Add(colType); } } for (var i = 0; i < AggColumnIndexes.Count; i++) { colTypes.Add("double"); } return(colTypes); }
private string GetGroupByType(string columnType, GroupByFunction groupByFunction) { if (groupByFunction == GroupByFunction.Month || groupByFunction == GroupByFunction.Year) { return("int"); } else { return(columnType); } }
private string GetGroupByStr(int columnIndex, GroupByFunction groupByFunction) { if (groupByFunction == GroupByFunction.Month) { return(string.Format("Month(Column_{0:D})", columnIndex)); } else if (groupByFunction == GroupByFunction.Year) { return(string.Format("Year(Column_{0:D})", columnIndex)); } else { return(string.Format("Column_{0:D}", columnIndex)); } }
private string GetGroupByFunctionUIText(string columnName, GroupByFunction groupByFunction) { if (groupByFunction == GroupByFunction.Month) { return(columnName + " Month"); } else if (groupByFunction == GroupByFunction.Year) { return(columnName + " Year"); } else { return(columnName); } }
public override string GetQuerySql() { var input1 = InputDict[Inputs[0]]; var selectCols = new List <string>(); var groupByCols = new List <string>(); for (var i = 0; i < GroupByColumnIndexes.Count; i++) { GroupByFunction groupByFunction = GroupByFunction.Date; if (i < GroupByFunctions.Count && GroupByFunctions[i].HasValue) { groupByFunction = GroupByFunctions[i].Value; } var groupByStr = GetGroupByStr(GroupByColumnIndexes[i], groupByFunction); selectCols.Add(string.Format("{0} AS Column_{1:D}", groupByStr, selectCols.Count)); groupByCols.Add(groupByStr); } for (var i = 0; i < AggFunctions.Count; i++) { AggregationFunction aggFunction = AggregationFunction.Count; if (i < AggFunctions.Count) { aggFunction = AggFunctions[i]; } var aggStr = GetAggStr( aggFunction != AggregationFunction.Count ? AggColumnIndexes[i] : 0, aggFunction); selectCols.Add(string.Format("{0} AS Column_{1:D}", aggStr, selectCols.Count)); } var sql = string.Format("SELECT {0} FROM {1}", String.Join(",", selectCols), input1.GetDependencySql()); if (GroupByColumnIndexes.Count > 0) { sql += string.Format(" GROUP BY {0}", String.Join(",", groupByCols)); } return(sql); }