Thanks for the reply. Finally got it working. The output actually get
printed out on client side not on TM side

On Tue, May 11, 2021 at 11:47 PM Jeff Zhang <zjf...@gmail.com> wrote:

> The result is printed in TM.
> It is local mode in IDE, so TM runs in your local jvm that's why you see
> the result
> While it is distributed mode (either yarn or standalone mode) when you are
> in sql-client, you should be able to see the result in TM logs.
>
>
> tao xiao <xiaotao...@gmail.com> 于2021年5月11日周二 下午11:40写道:
>
>> Does anyone help with this question?
>>
>> On Thu, May 6, 2021 at 3:26 PM tao xiao <xiaotao...@gmail.com> wrote:
>>
>>> Hi team,
>>>
>>> I wrote a simple SQL job to select data from Kafka. I can see results
>>> printing out in IDE but when I submit the job to a standalone cluster in
>>> CLI there is no result shown. I am sure the job is running well in the
>>> cluster with debug log suggesting that the kafka consumer is fetching data
>>> from Kafka. I enabled debug log in CLI and I don't see any obvious log.
>>> Here is the job code snippet
>>>
>>> public static void main(String[] args) throws Exception {
>>>   StreamTableEnvironment tableEnv = StreamTableEnvironment
>>>       
>>> .create(StreamExecutionEnvironment.getExecutionEnvironment().setParallelism(1));
>>>
>>>   String sqls = new String(Files.readAllBytes(Paths.get(args[0])));
>>>   splitIgnoreQuota(sqls, ';').forEach(sql -> {
>>>     TableResult tableResult = tableEnv.executeSql(sql);
>>>     tableResult.print();
>>>   });
>>> }
>>>
>>> It simply parses a sql file and execute the statements
>>>
>>> Here is the SQL statements
>>>
>>> CREATE TABLE t1 (
>>>   `f1` STRING,
>>>   `f2` STRING
>>> ) WITH (
>>>   'connector' = 'kafka',
>>>   'topic' = 'topic',
>>>   'properties.group.id' = 'test1',
>>>   'properties.max.partition.fetch.bytes' = '16384',
>>>   'properties.enable.auto.commit' = 'false',
>>>   'properties.bootstrap.servers' = 'kafka:9092',
>>>   'scan.startup.mode' = 'earliest-offset',
>>>   'format' = 'json'
>>> );
>>>
>>> SELECT * FROM t1
>>>
>>>
>>> Below is the result I got from IDE
>>> | +I | b8f5 |           abcd |
>>> | +I | b8f5 |           abcd |
>>>
>>> And this is the result from CLI
>>> bin/flink run  -m localhost:8081 -c kafka.sample.flink.SQLSample
>>> ~/workspaces/kafka-sample/target/kafka-sample-0.1.2-jar-with-dependencies.jar
>>> /sample.sql
>>> +--------+
>>> | result |
>>> +--------+
>>> |     OK |
>>> +--------+
>>> 1 row in set
>>> Job has been submitted with JobID ace45d2ff850675243e2663d3bf11701
>>> +----+--------------------------------+--------------------------------+
>>> | op |                           uuid |                            ots |
>>> +----+--------------------------------+--------------------------------+
>>>
>>>
>>> --
>>> Regards,
>>> Tao
>>>
>>
>>
>> --
>> Regards,
>> Tao
>>
>
>
> --
> Best Regards
>
> Jeff Zhang
>


-- 
Regards,
Tao

Reply via email to