private IList <TableColumnDesc> ValidateExpressions( IList <CreateTableColumn> columns, EPServicesContext services, StatementContext statementContext) { ISet <string> columnNames = new HashSet <string>(); IList <TableColumnDesc> descriptors = new List <TableColumnDesc>(); var positionInDeclaration = 0; foreach (var column in columns) { var msgprefix = "For column '" + column.ColumnName + "'"; // check duplicate name if (columnNames.Contains(column.ColumnName)) { throw new ExprValidationException("Column '" + column.ColumnName + "' is listed more than once"); } columnNames.Add(column.ColumnName); // determine presence of type annotation var optionalEventType = ValidateExpressionGetEventType(msgprefix, column.Annotations, services.EventAdapterService); // aggregation node TableColumnDesc descriptor; if (column.OptExpression != null) { var validated = ValidateAggregationExpr(column.OptExpression, optionalEventType, services, statementContext); descriptor = new TableColumnDescAgg(positionInDeclaration, column.ColumnName, validated, optionalEventType); } else { var unresolvedType = EventTypeUtility.BuildType( new ColumnDesc( column.ColumnName, column.OptTypeName, column.OptTypeIsArray ?? false, column.OptTypeIsPrimitiveArray ?? false), services.EngineImportService); descriptor = new TableColumnDescTyped( positionInDeclaration, column.ColumnName, unresolvedType, column.PrimaryKey ?? false); } descriptors.Add(descriptor); positionInDeclaration++; } return(descriptors); }
private compat.collections.Pair<IList<TableColumnDesc>, IList<StmtClassForgeableFactory>> ValidateExpressions( IList<CreateTableColumn> columns, StatementCompileTimeServices services) { ISet<string> columnNames = new HashSet<string>(); IList<TableColumnDesc> descriptors = new List<TableColumnDesc>(); var positionInDeclaration = 0; var additionalForgeables = new List<StmtClassForgeableFactory>(); foreach (var column in columns) { var msgprefix = "For column '" + column.ColumnName + "'"; // check duplicate name if (columnNames.Contains(column.ColumnName)) { throw new ExprValidationException("Column '" + column.ColumnName + "' is listed more than once"); } columnNames.Add(column.ColumnName); // determine presence of type annotation var optionalEventType = ValidateExpressionGetEventType(msgprefix, column.Annotations, services); // aggregation node TableColumnDesc descriptor; if (column.OptExpression != null) { var pair = ValidateAggregationExpr(column.OptExpression, optionalEventType, services); descriptor = new TableColumnDescAgg(positionInDeclaration, column.ColumnName, pair.First, optionalEventType); additionalForgeables.AddRange(pair.Second); } else { var unresolvedType = EventTypeUtility.BuildType( new ColumnDesc(column.ColumnName, column.OptType.ToEPL()), services.ImportServiceCompileTime); descriptor = new TableColumnDescTyped( positionInDeclaration, column.ColumnName, unresolvedType, column.PrimaryKey.GetValueOrDefault(false)); } descriptors.Add(descriptor); positionInDeclaration++; } return new compat.collections.Pair<IList<TableColumnDesc>, IList<StmtClassForgeableFactory>>(descriptors, additionalForgeables); }