@Test public void longestStringTest() { Schema fieldSchema = Schema.of(Schema.Type.STRING); Schema schema = Schema.recordOf("test", Schema.Field.of("x", Schema.nullableOf(fieldSchema))); test(new LongestString("x", fieldSchema), schema, "x", "absorption", Arrays.asList("heart", "ditch", "extent", "effective", "absorption"), new LongestString("x", fieldSchema)); test(new LongestString("x", fieldSchema), schema, "x", "effective", Arrays.asList("heart", "ditch", "extent", "effective", null), new LongestString("x", fieldSchema)); }
public LongestString(String fieldName, Schema fieldSchema) { this.fieldName = fieldName; Type inputType = fieldSchema.isNullable() ? fieldSchema.getNonNullable().getType() : fieldSchema.getType(); if (!inputType.equals(Type.STRING)) { throw new IllegalArgumentException( String.format("Field '%s' is of unsupported non-string type '%s'. ", fieldName, inputType)); } }
LongestString implements AggregateFunction<String, LongestString> { public LongestString(String fieldName, Schema fieldSchema) { this.fieldName = fieldName; Type inputType = fieldSchema.isNullable() ? fieldSchema.getNonNullable().getType() : fieldSchema.getType(); if (!inputType.equals(Type.STRING)) { throw new IllegalArgumentException( String.format("Field '%s' is of unsupported non-string type '%s'. ", fieldName, inputType)); } } }
LongestString implements AggregateFunction<String, LongestString> { public LongestString(String fieldName, Schema fieldSchema) { this.fieldName = fieldName; Type inputType = fieldSchema.isNullable() ? fieldSchema.getNonNullable().getType() : fieldSchema.getType(); if (!inputType.equals(Type.STRING)) { throw new IllegalArgumentException( String.format("Field '%s' is of unsupported non-string type '%s'. ", fieldName, inputType)); } } LongestString(String fieldName, Schema fieldSchema); }
LongestString implements AggregateFunction<String, LongestString> { public LongestString(String fieldName, Schema fieldSchema) { this.fieldName = fieldName; Type inputType = fieldSchema.isNullable() ? fieldSchema.getNonNullable().getType() : fieldSchema.getType(); if (!inputType.equals(Type.STRING)) { throw new IllegalArgumentException( String.format("Field '%s' is of unsupported non-string type '%s'. ", fieldName, inputType)); } } LongestString(String fieldName, Schema fieldSchema); @Override void initialize(); @Override void mergeValue(StructuredRecord record); @Override void mergeAggregates(LongestString otherAgg); @Override String getAggregate(); @Override Schema getOutputSchema(); }
LongestString implements AggregateFunction<String, LongestString> { public LongestString(String fieldName, Schema fieldSchema) { this.fieldName = fieldName; Type inputType = fieldSchema.isNullable() ? fieldSchema.getNonNullable().getType() : fieldSchema.getType(); if (!inputType.equals(Type.STRING)) { throw new IllegalArgumentException( String.format("Field '%s' is of unsupported non-string type '%s'. ", fieldName, inputType)); } } LongestString(String fieldName, Schema fieldSchema); @Override void initialize(); @Override void mergeValue(StructuredRecord record); @Override void mergeAggregates(LongestString otherAgg); @Override String getAggregate(); @Override Schema getOutputSchema();  }