espertechinc / esper

Esper Complex Event Processing, Streaming SQL and Event Series Analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPE on auditing last() window function

donatio-nikolashin opened this issue · comments

public class EsperLastFuncTest {

    @Test
    public void reproduce_npe_on_last_function_audit() throws Exception {
        Map<String, Object> typeMap = Map.of(
                "long_field", Long.class
        );
        Configuration configuration = new Configuration();
        configuration.getCommon().addEventType("EVENT", typeMap);

        Module module = new Module();
        module.setName("MODULE");
        module.setItems(
                List.of(
                        new ModuleItem("create window EVENT_WINDOW#length(2) as select * from EVENT"),
                        new ModuleItem("insert into EVENT_WINDOW select * from EVENT(long_field>0)"),
                        new ModuleItem("@Audit select *, window() from EVENT_WINDOW having last(long_field, 1) > 10 ")
                )
        );

        EPRuntime runtime = EPRuntimeProvider.getRuntime(UUID.randomUUID().toString(), configuration);
        compileDeploy(runtime, module);

        runtime.getEventService().sendEventMap(Map.of("long_field", 5L), "EVENT");
        runtime.getEventService().sendEventMap(Map.of("long_field", 5L), "EVENT");
    }

    public static void compileDeploy(EPRuntime runtime, Module module) throws Exception {
        CompilerArguments args = new CompilerArguments();
        args.setConfiguration(runtime.getConfigurationDeepCopy());
        args.getPath().add(runtime.getRuntimePath());
        EPCompiler compiler = EPCompilerProvider.getCompiler();
        EPCompiled compiled = compiler.compile(module, args);
        runtime.getDeploymentService().deploy(compiled);
    }
    
}