Flink实时数据的时态表join 我这里为啥一直没有输出为什么? String sql = "select o.,r.rate from alan_orderTable as o,Lateral table (alan_rateDim(o.order_time)) r where r.currency = o.currency ";
// String sql = "select o.,r.rate from alan_orderTable as o left join alan_rateTable FOR SYSTEM_TIME AS OF o.order_time AS r on r.currency = o.currency ";
// // 关联查询
Table result = tenv.sqlQuery(sql);
// 打印输出
DataStream resultDs = tenv.toAppendStream(result, Row.class);
resultDs.print("resultDs ---- >");
env.execute();
可能的原因有以下几点:
alan_orderTable
和alan_rateDim
中有数据。建议按照以下步骤进行排查:
alan_orderTable
和alan_rateDim
中是否有数据。import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.types.Row;
public class FlinkJoinExample {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tenv = StreamTableEnvironment.create(env);
// 注册数据源
tenv.executeSql("CREATE TABLE alan_orderTable (...) WITH (...)");
tenv.executeSql("CREATE TABLE alan_rateDim (...) WITH (...)");
// SQL查询
String sql = "SELECT o., r.rate FROM alan_orderTable AS o, LATERAL TABLE (alan_rateDim(o.order_time)) r WHERE r.currency = o.currency";
Table result = tenv.sqlQuery(sql);
// 转换为DataStream并打印输出
DataStream<Row> resultDs = tenv.toAppendStream(result, Row.class);
resultDs.print("resultDs ---- >");
env.execute("Flink Join Example");
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
实时计算Flink版是阿里云提供的全托管Serverless Flink云服务,基于 Apache Flink 构建的企业级、高性能实时大数据处理系统。提供全托管版 Flink 集群和引擎,提高作业开发运维效率。