esper icon indicating copy to clipboard operation
esper copied to clipboard

PlugInSingleRowFunction and stream property name conflict

Open zhucj1981 opened this issue 4 years ago • 1 comments

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();
		}
	}
}

zhucj1981 avatar Apr 30 '20 17:04 zhucj1981

Since this change can affect EPL behavior it is labeled for next major release.

bernhardttom avatar May 11 '20 18:05 bernhardttom