FilterUtils { public static Predicate<IndexedRecord> toPredicate(final String sqlExpr, final Schema recSchema) throws SqlParseException, ValidationException, RelConversionException { return toPredicate(sqlExpr, JAVA_TYPE_FACTORY, recSchema); } private  FilterUtils(); static SqlNode parse(final String expr); static Predicate<IndexedRecord> toPredicate(final String sqlExpr,
          final Schema recSchema); static Predicate<IndexedRecord> toPredicate(final String sqlExpr,
          final JavaTypeFactoryImpl javaTypeFactoryImpl,
          final Schema recSchema); static Predicate<IndexedRecord> toPredicate(final List<RexNode> filter, final RelDataType rowType); static Predicate<IndexedRecord> toPredicate(final List<RexNode> filter,
          final JavaTypeFactoryImpl javaTypeFactoryImpl, final RelDataType rowType); static Predicate<IndexedRecord> toPredicate(@Nullable final Iterable<String> expr,
          final Schema recSchema);  }
@Test public void testzfilterRecord() throws SqlParseException, ValidationException, RelConversionException { Schema subRecSchema = SchemaBuilder.record("SubRecord") .fields().name("key").type().stringType().noDefault() .requiredString("value").endRecord(); Schema recBSchema = SchemaBuilder.record("RecordB") .fields().name("id").type().intType().noDefault() .requiredString("name") .requiredString("text") .name("adate").type(Schemas.dateString()).noDefault() .name("meta").type(Schema.createArray(subRecSchema)).noDefault() .name("meta2").type(subRecSchema).noDefault() .endRecord(); GenericRecord subRec = new GenericData.Record(subRecSchema); subRec.put("key", "key1"); subRec.put("value", "val1"); GenericRecord recb1 = new GenericData.Record(recBSchema); recb1.put("id", 1); recb1.put("name", "Beam"); recb1.put("text", "bla"); recb1.put("adate", LocalDate.now()); recb1.put("meta", Collections.singletonList(subRec)); recb1.put("meta2", subRec); Predicate<IndexedRecord> p = FilterUtils.toPredicate("name = 'Beam'", recBSchema); assertTrue(p.test(recb1)); Predicate<IndexedRecord> p2 = FilterUtils.toPredicate("name is null or text like '%bla%'", recBSchema); assertTrue(p2.test(recb1)); Predicate<IndexedRecord> p3 = FilterUtils.toPredicate("name is null", recBSchema); assertFalse(p3.test(recb1)); }