Apache Hudi初探(四)(与flink的结合)--Flink Sql中hudi的createDynamicTableSource/createDynamicTableSink/是怎么被调用

文章讲述了Flink中动态表操作如何在SQL转换阶段调用,以及HoodieCatalogFactory在创建自定义表目录中的关键作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景

本篇文章主要是结合hui中涉及到的HoodieTableFactoryHoodieCatalogFactory来说明一下Flink中createDynamicTableSource/createDynamicTableSink/createCatalog是什么时候被调用的

闲说杂谈

先上图:
在这里插入图片描述

createDynamicTableSink调用逻辑

最主要的逻辑还是在PlannerBasetranslate的方法中:

  override def translate(
      modifyOperations: util.List[ModifyOperation]): util.List[Transformation[_]] = {
    validateAndOverrideConfiguration()
    if (modifyOperations.isEmpty) {
      return List.empty[Transformation[_]]
    }

    val relNodes = modifyOperations.map(translateToRel)
    val optimizedRelNodes = optimize(relNodes)
    val execGraph = translateToExecNodeGraph(optimizedRelNodes)
    val transformations = translateToPlan(execGraph)
    cleanupInternalConfigurations()
    transformations
  }

以上逻辑是SQL转换为Flink transformation的流程,对应的图为:

https://tianchi.aliyun.com/forum/post/116378 中的图

对应到我们这里的调用流程为:

modifyOperations.translateToRel
      ||
      \/
planBase.getTableSink
      ||
      \/
factoryUtil.createTableSink
      ||
      \/
HoodieTableFactory.createDynamicTableSink

也说该方法的调用是在逻辑生成阶段的.(createDynamicTableSource方法的调用逻辑也是一样的)

createCatalog(hudi)调用逻辑

Flink中要创建并且使用自定义的catalog可以通过如下方式:

// java中 
  tableEnv.registerCatalog("myhive", catalog);
// sql中
CREATE CATALOG hoodie_catalog
WITH (
  'type'='hudi',
  'catalog.path' = '${catalog root path}', -- only valid if the table options has no explicit declaration of table path
  'hive.conf.dir' = '${dir path where hive-site.xml is located}',
  'mode'='hms' -- also support 'dfs' mode so that all the table metadata are stored with the filesystem
);

对应到SQL中的调用逻辑为

TableEnvironmentImpl.executeInternal
      ||
      \/
TableEnvironmentImpl.createCatalog
      ||
      \/
FactoryUtil.createCatalog
      ||
      \/
HoodieCatalogFactory.createCatalog

最终会调用catalogManager.registerCatalog方法,用catalogManager管理了起来,这样在用到的时候就会调用该get方法得到对应的catalog

其他

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值