In execute method i use the following code to return empty rows:
return new BufferedDataTable[] {};
but got error
java.lang.IllegalStateException: Invalid result. Execution failed. Reason: Incorrect implementation; the execute method in TSDBNodeModel returned null or an incorrect number of output tables.
This error is thrown because the number of output tables specified in the constructor of your NodeModel differs from the number of tables you return.
protected YourNodeNodeModel() {
super(1 /* Number of input ports*/, 1 /* Number of output ports*/);
}
If you set the number of output ports to zero, your node will execute without that exception. In that case you can also just return null; instead of return new BufferedDataTable[] {};.
You return 0 tables but you’re saying you’re going to return 1 in the constructor.
Do you want no table or an empty table? If you want an empty table you need to create the table and then return it rather than an empty array of tables.
BufferedDatatable emptyTable = createEmptyTable(exec);
return new BufferedDataTable {emptyTable}
Where the createEmptyTable() method creates a table with no columns and no rows. I’ve not got a working KNIME development environment on the machine I’m on to create a working example.
Hi @lou,
do you want to return a table without any content at all, or, as in your example, with a single row containing empty strings? If you only want an empty table with no rows and no columns, you can use this:
If you want it to have some columns, you have to modify this line: BufferedDataContainer container = exec.createDataContainer(new DataTableSpecCreator().createSpec());. Here you have to create a table spec matching your required columns and then pass that to the container creation.
Kind regards
Alexander
// Edit: I changed the code a bit because the container must be closed before accessing the table using getTable().