开发者社区> 问答> 正文

Flink1.13.1自定义Catalog问题出错怎么解决?

Flink1.13.1在Catalog方面修改比较大,特别是一些方法的实现上

JdbcCatalogFactory implements CatalogFactory中:

核心三个方法全部过期:

public Map<String, String> requiredContext()

 public List<String> supportedProperties()

 public Catalog createCatalog(String name, Map<String, String> properties)

新的替换方法:

  public Set<ConfigOption<?>> requiredOptions()

  public Set<ConfigOption<?>> optionalOptions()

  public Catalog createCatalog(Context context)

用新的方法打包之后运行:

Exception in thread "main" org.apache.flink.table.api.TableException: Required context of factory 'com.apache.flink.catalog.factory.MysqlCatalogFactory' must not be null

跟踪代码进去发现,

     private static Map<String, String> normalizeContext(TableFactory factory) {

        Map<String, String> requiredContext = factory.requiredContext();

        if (requiredContext == null) {

            throw new TableException(

                    String.format(

                            "Required context of factory '%s' must not be null.",

       }                     factory.getClass().getName()));

看错误是因为requiredContext == null了,其实就是上面requiredContext()没有实现,不明白新版api都把这个方法过期了,为啥在后面还要调用判断他?*来自志愿者整理的flink邮件归档

展开
收起
EXCEED 2021-12-02 14:57:16 1288 0
1 条回答
写回答
取消 提交回答
  • 新版的 CatalogFactory 实现了 Factory,这意味着当前的所有的 connector、format 以及 Catalog 都实现了相同的接口,保持了统一性。而保持原来的方法,更多是为了暂时的兼容性( 我的理解 ): 如果 某个Catalog 从低版本迁移到高版本只需要添加一些新的接口方法,而不需要删除之前的逻辑。之后的版本可能会删除这些已经被deprecated 方法。

    *来自志愿者整理的FLINK邮件归档

    2021-12-02 15:11:10
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Flink CDC Meetup PPT - 龚中强 立即下载
Flink CDC Meetup PPT - 王赫 立即下载
Flink CDC Meetup PPT - 覃立辉 立即下载