apache / paimon

Apache Paimon is a lake format that enables building a Realtime Lakehouse Architecture with Flink and Spark for both streaming and batch operations.
https://paimon.apache.org/
Apache License 2.0
2.43k stars 957 forks source link

[Feature] Method hasNext blocks the iterator when the data is not arrived #1377

Closed yuzyf closed 1 year ago

yuzyf commented 1 year ago

Search before asking

Motivation

    TableResult tableResult = tenv.executeSql("SELECT project__id,dept__id FROM paimon_catalog.test.production_plan_development WHERE plan_id = '" + planId + "' AND version = " + version);
    CloseableIterator<Row> iterator = tableResult.collect();
    if (iterator.hasNext()) {}

现在这段代码查不到数据的话、就会在iterator.hasNext()进行阻塞、有数据就不会阻塞、我的理解是hasNext、没有数据不应该返回false直接跳过吗、现在有什么可以修改的方案吗、谢谢

Solution

No response

Anything else?

No response

Are you willing to submit a PR?

JingsongLi commented 1 year ago

@yuzyf This is a Flink issue, you are using streaming mode, so the iterator will be blocked to wait next record.

You should use batch mode...

JingsongLi commented 1 year ago

And please use English in github issue.

yuzyf commented 1 year ago

@yuzyf This is a Flink issue, you are using streaming mode, so the iterator will be blocked to wait next record.

You should use batch mode...

I have set in my code

image
JingsongLi commented 1 year ago

@yuzyf If you are using batch mode, you can launch a thread to iterate records.

FangYongs commented 1 year ago

I think the method hasNext blocks the iterator is a valid action when no data has arrived. If a iterator returns false in hasNext(), it means the iterator has no more data. The execution of job is asynchronous, no data at the moment does means the iterator has no more data.