开发者社区> 问答> 正文

flink sql报错 Could not find any factory for identif

各位好,写了个demo,代码如下,在本地跑没有问题,提交到yarn session上报错: Caused by: org.apache.flink.table.api.ValidationException: Could not find any factory for identifier 'kafka' that implements 'org.apache.flink.table.factories.DynamicTableSourceFactory' in the classpath. 请问是什么原因导致的呢?

代码如下:


StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); EnvironmentSettings settings = EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build(); StreamTableEnvironment tenv = StreamTableEnvironment.create(env, settings);

tenv.executeSql("CREATE TABLE test_table (\n" + " id INT,\n" + " name STRING,\n" + " age INT,\n" + " create_at TIMESTAMP(3)\n" + ") WITH (\n" + " 'connector' = 'kafka',\n" + " 'topic' = 'test_json',\n" + " 'properties.bootstrap.servers' = 'localhost:9092',\n" + " 'properties.group.id' = 'testGroup',\n" + " 'format' = 'json',\n" + " 'scan.startup.mode' = 'latest-offset'\n" + ")"); Table table = tenv.sqlQuery("select * from test_table"); tenv.toRetractStream(table, Row.class).print(); env.execute("flink 1.11.0 demo");

pom 文件如下:

<scala.binary.version>2.11</scala.binary.version> <flink.version>1.11.0</flink.version> org.apache.flink

flink-table-planner-blink_${scala.binary.version} ${flink.version} org.apache.flink

flink-table-runtime-blink_${scala.binary.version} ${flink.version} org.apache.flink flink-json ${flink.version} org.apache.flink

flink-connector-kafka_${scala.binary.version} ${flink.version} org.apache.flink

flink-connector-kafka-0.11_${scala.binary.version} ${flink.version} org.apache.flink

flink-connector-kafka_${scala.binary.version} ${flink.version} org.apache.flink flink-core ${flink.version} org.apache.flink flink-clients_${scala.binary.version} ${flink.version} org.apache.flink flink-table-common ${flink.version}

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

展开
收起
小阿矿 2021-12-06 15:29:38 2920 0
1 条回答
写回答
取消 提交回答
  • 这个报错是pom中缺少了 Kafka SQL connector的依赖,你引入的依赖都是Kafka datastream connector 的依赖,正确的依赖是:flink-sql-connector-kafka-${version}_${scala.binary.version} 可以参考官网文档[1], 查看和下载SQL Client Jar. 另外, Kafka SQL connector 和 Kafka datastream connector 同时引用是会冲突的,请根据你的需要使用。

    [1]https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/connectors/kafka.html https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/connectors/kafka.html

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

    2021-12-06 17:48:35
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

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