@Test void allFieldPresentAndCompatible() throws EvaluationException { Table table = Table.create( DoubleColumn.create("double", new double[] {1}), FloatColumn.create("float", new float[] {1}), IntColumn.create("integer", new int[] {1}), StringColumn.create("string", new String[] {"1"}), BooleanColumn.create("boolean", new boolean[] {true}), DateColumn.create("date", new LocalDate[] {LocalDate.MIN}) ); List<Field> outputs = Arrays.asList( new Field("double", DataType.DOUBLE), new Field("float", DataType.FLOAT), new Field("integer", DataType.INTEGER), new Field("string", DataType.STRING), new Field("boolean", DataType.BOOLEAN), new Field("date", DataType.DATE) ); TableUtils.allFieldPresentAndCompatible(table, outputs); List<Field> outputs2 = Arrays.asList( new Field("double", DataType.STRING), new Field("float", DataType.FLOAT), new Field("integer", DataType.INTEGER), new Field("string", DataType.STRING), new Field("boolean", DataType.BOOLEAN), new Field("date", DataType.DATE) ); assertThrows( EvaluationException.class, () -> TableUtils.allFieldPresentAndCompatible(table, outputs2) ); }
public static void allFieldPresentAndCompatible(Table table, List<Field> fields) throws EvaluationException { List<String> columnNames = table.columnNames(); String missingInputs = fields .stream() .filter(field -> { if (!columnNames.contains(field.getName())) { return true; } return !isCompatibleTypeColumn(table.column(field.getName()).type(), field.getType()); }) .map(field -> String.format("(%s,%s)", field.getName(), field.getType())) .collect(Collectors.joining(",")); if (!StringUtils.isEmpty(missingInputs)) { throw new EvaluationException( String.format("Required fields %s not found or not compatible in the Table", missingInputs) ); } }
TableUtils { public static void allFieldPresentAndCompatible(Table table, List<Field> fields) throws EvaluationException { List<String> columnNames = table.columnNames(); String missingInputs = fields .stream() .filter(field -> { if (!columnNames.contains(field.getName())) { return true; } return !isCompatibleTypeColumn(table.column(field.getName()).type(), field.getType()); }) .map(field -> String.format("(%s,%s)", field.getName(), field.getType())) .collect(Collectors.joining(",")); if (!StringUtils.isEmpty(missingInputs)) { throw new EvaluationException( String.format("Required fields %s not found or not compatible in the Table", missingInputs) ); } } }
TableUtils { public static void allFieldPresentAndCompatible(Table table, List<Field> fields) throws EvaluationException { List<String> columnNames = table.columnNames(); String missingInputs = fields .stream() .filter(field -> { if (!columnNames.contains(field.getName())) { return true; } return !isCompatibleTypeColumn(table.column(field.getName()).type(), field.getType()); }) .map(field -> String.format("(%s,%s)", field.getName(), field.getType())) .collect(Collectors.joining(",")); if (!StringUtils.isEmpty(missingInputs)) { throw new EvaluationException( String.format("Required fields %s not found or not compatible in the Table", missingInputs) ); } }  }
TableUtils { public static void allFieldPresentAndCompatible(Table table, List<Field> fields) throws EvaluationException { List<String> columnNames = table.columnNames(); String missingInputs = fields .stream() .filter(field -> { if (!columnNames.contains(field.getName())) { return true; } return !isCompatibleTypeColumn(table.column(field.getName()).type(), field.getType()); }) .map(field -> String.format("(%s,%s)", field.getName(), field.getType())) .collect(Collectors.joining(",")); if (!StringUtils.isEmpty(missingInputs)) { throw new EvaluationException( String.format("Required fields %s not found or not compatible in the Table", missingInputs) ); } }  static void createTableOutputColumns(Table table, List<? extends Field> fields); static Number getNumberFromRow(String name, Row row); static boolean isMissing(Row row, Column<?> column); static Optional<NumberColumn> getNumberColumn(String name, Table table); static void allFieldPresentAndCompatible(Table table, List<Field> fields); static Column<?> listToColumn(List<Object> list, Field expectedField); }
TableUtils { public static void allFieldPresentAndCompatible(Table table, List<Field> fields) throws EvaluationException { List<String> columnNames = table.columnNames(); String missingInputs = fields .stream() .filter(field -> { if (!columnNames.contains(field.getName())) { return true; } return !isCompatibleTypeColumn(table.column(field.getName()).type(), field.getType()); }) .map(field -> String.format("(%s,%s)", field.getName(), field.getType())) .collect(Collectors.joining(",")); if (!StringUtils.isEmpty(missingInputs)) { throw new EvaluationException( String.format("Required fields %s not found or not compatible in the Table", missingInputs) ); } }  static void createTableOutputColumns(Table table, List<? extends Field> fields); static Number getNumberFromRow(String name, Row row); static boolean isMissing(Row row, Column<?> column); static Optional<NumberColumn> getNumberColumn(String name, Table table); static void allFieldPresentAndCompatible(Table table, List<Field> fields); static Column<?> listToColumn(List<Object> list, Field expectedField);  }