开发者社区 问答 正文

PyFlink中通过 Table API定义作业的计算逻辑的方法是什么?

PyFlink中通过 Table API定义作业的计算逻辑的方法是什么?

展开
收起
游客qzzytmszf3zhq 2021-12-07 14:44:24 352 分享 版权
1 条回答
写回答
取消 提交回答
  • 得到 source 表之后,接下来就可以使用 Table API 中提供的各种操作,定义作业的计算逻辑,对表进行各种变换了,比如:
    
    @udf(result_type=DataTypes.STRING())
    def sub_string(s: str, begin: int, end: int):
       return s[begin:end]
    
    transformed_tab = tab.select(sub_string(col('a'), 2, 4))
    
    2021-12-07 14:44:38
    赞同 展开评论