Hi everyone,
1. I am migrating a workflow from KNIME server to Business Hub, for which I am working on KNIME 5.3.3 and using a Java Snippet that creates a table in BigQuery with the following script:
// system imports
import org.knime.base.node.jsnippet.expression.AbstractJSnippet;
import org.knime.base.node.jsnippet.expression.Abort;
import org.knime.base.node.jsnippet.expression.Cell;
import org.knime.base.node.jsnippet.expression.ColumnException;
import org.knime.base.node.jsnippet.expression.TypeException;
import static org.knime.base.node.jsnippet.expression.Type.*;
import java.util.Date;
import java.util.Calendar;
import org.w3c.dom.Document;
// Your custom imports:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Collectors;
// system variables
public class JSnippet extends AbstractJSnippet {
// Fields for input flow variables
/** Input flow variable: “project” /
public String v_project;
/* Input flow variable: “dataset” /
public String v_dataset;
/* Input flow variable: “table_name” /
public String v_table_name;
/* Input flow variable: “file_location” /
public String v_file;
/* Input flow variable: “schema_location” */
public String v_schema;
// Fields for output columns
/** Output column: “Resultado” /
public String out_Resultado;
/* Output column: “command” /
public String out_command;
/* Output column: “Message” */
public String out_Message;
// Your custom variables:
int exitValue;
// expression start
public void snippet() throws TypeException, ColumnException, Abort {
// Enter your code here:
String command = new String {“bq”, “–headless=true”, “-q”, “mk”,“–table”,“-f”,
v_project+“:”+v_dataset+“.”+v_table_name,
v_schema};
try {
Process p = Runtime.getRuntime().exec
(
command
);
//Wait for execute and get exit code
exitValue = p.waitFor();
out_Resultado = String.valueOf(exitValue);
// Get error message
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
out_Message = stdInput.lines().collect(Collectors.joining()) + stdError.lines().collect(Collectors.joining());
// Get executed command
out_command = String.join(" ", command);
} catch (Exception e) {
out_Resultado = “False”;
e.printStackTrace();
}
if (exitValue !=0){
throw new Abort(out_Message);
}
// expression end
2. The parameters that this node receives are those necessary to create a table in BigQuery, among them is schema, which is a path in string format (because the Java snippet does not recognize the path format) of a .json file located in a temporary folder of the computer/virtual machine, with the structure of the tables that BigQuery creates.
3. When executing the Java snippet node, it throws the following error:
4. When this workflow was working (in KNIME server), a local path of the computer or virtual machine was sent to the schema variable, but when migrating to the HUB, local paths are not allowed and, therefore, this node stops working, since the HUB creates relative paths that point to the HUB.
5. How can I make it recognize the relative path provided by the HUB?
I am very grateful if you can help me with this problem.