esper
esper copied to clipboard
PlugInSingleRowFunction and stream property name conflict
When PlugInSingleRowFunction's name and stream property name are same, compiler will treat property name as function.
import java.util.LinkedHashMap;
import java.util.Map;
import com.espertech.esper.common.client.EPCompiled;
import com.espertech.esper.common.client.configuration.Configuration;
import com.espertech.esper.common.client.configuration.compiler.ConfigurationCompilerByteCode;
import com.espertech.esper.compiler.client.CompilerArguments;
import com.espertech.esper.compiler.client.EPCompiler;
import com.espertech.esper.compiler.client.EPCompilerProvider;
public class Test6 {
public static String id()
{
return "1";
}
public static void main(String[] args) {
Configuration configuration = new Configuration();
ConfigurationCompilerByteCode byteCode = configuration.getCompiler().getByteCode();
byteCode.setAllowSubscriber(true);
byteCode.setAccessModifiersPublic();
Map<String, Object> columns = new LinkedHashMap<>();
columns.put("id", String.class);
configuration.getCommon().addEventType("bar", columns);
configuration.getCompiler().addPlugInSingleRowFunction("id", "Test6", "id");
CompilerArguments arguments = new CompilerArguments(configuration);
EPCompiler epCompiler = EPCompilerProvider.getCompiler();
try {
String[] epls = {
"create schema A (id string)",
"insert into A select id from bar"
};
for(String epl:epls) {
EPCompiled compiled = epCompiler.compile(epl, arguments);
arguments.getPath().add(compiled);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Since this change can affect EPL behavior it is labeled for next major release.