Search code examples
javaapache-flinkflink-streamingflink-sql

Not able to submit arguments with values within single quote to flink job


I am trying to submit my jar with args. I am using flink Rest Api to send my args in json format. My input sample in java is

JSONObject json = new JSONObject();
 json.put("programArgs","--bootstrap.server \"localhost:9092\" --zookeeper.server \"localhost:2181\" --query \"where agentHost='192.168.170.111'\" --source.topic \"demo1\" --dest.topic \"rules\" --job.id \"123\" --extra.info \"sdcdscsd\"");
httpPost.setEntity(new StringEntity(json.toJSONString()));

when I give exactly these args my job runs via IDE, however when I send it via rest api my query arg comes without the single quotes. And hence I am getting Calcite sql parse exception.

How do I resolve this?


Solution

  • You need to send the parameters as a list of parameters instead of as a string. You can do this by setting the programArgsList field instead which is of type array:

    json.put("programArgsList", Arrays.asList("--bootstrap.server", "localhost:9092", "--zookeeper.server", "localhost:2181", "--query", "where agentHost='192.168.170.111'", "--source.topic", "demo1", ...));
    

    That way Flink won't remove the single quotes as part of the input parsing. See FLINK-10295 for more information.