0

I have a Flink application where I run a custom SQL parser and parse the SQL provided by user. This generates a Predicate tree which gets evaluated once the streaming application starts.

I use JSQL parser to parse the SQL. When running the application, I get a weird Serialization error which I didn't get before. I haven't changed anything in the code, yet I get this error suddenly using Flink API.

Below is the code snippet where it is failing and I get a java.io.NotSerializableException: com.eventwatch.query.OperationType$$Lambda$1272/411594792:

    private Predicate<RowMapPair> checkEquals(String type, String column, Object value) {
        log.debug("string: " + value);
        StringValue stringValue = new StringValue((""+value).trim());
        log.debug("stringValue: " + stringValue.toString());
        return (rowMapPair) -> { // PLACE OF RUNTIME EXCEPTION
          MapState<String, Pair> mapState = rowMapPair.getMapState();
          Row row = rowMapPair.getRow();
          String _id = String.valueOf(row.getFieldAs("_id"));
          String key = String.join("__", _id, column);

          String curVal = null;
          try {
            Pair val = mapState.get(key);
            log.debug("** val: {}", mapState.get(key));
            if (Objects.nonNull(val)) {
              curVal = String.valueOf(val.getValue());
            } else {
              return false;
            }
          } catch (Exception e) {
            log.error("Error: {}", e.getMessage(), e);
            throw new RuntimeException(e);
          }
          return curVal.equalsIgnoreCase(stringValue.getValue());
        };
    }

Below is the stack trace:

Caused by: java.io.NotSerializableException: com.eventwatch.query.OperationType$$Lambda$1272/411594792
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
        at org.apache.flink.util.InstantiationUtil.serializeObject(InstantiationUtil.java:632)
        at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:143)
guru
  • 409
  • 4
  • 21

0 Answers0