表选项不包含选项键

表选项不包含选项键

本文介绍了表选项不包含选项键“连接器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用flink sql客户端创建一个配置单元表.

I would like to create a hive table using flink sql client.

我可以成功创建表t2,但是当我查询t2时,它会抱怨

I could create the table t2 successfully, but when i query t2, it complains

Table options do not contain an option key 'connector' for discovering a connector.

我已在conf/sql-client-defaults.yaml文件中将执行类型设置为批处理,

I have set the execution type to be batch in the conf/sql-client-defaults.yaml file,

我会问这里是什么问题.谢谢!

I would ask what the problem is here. Thanks!

Flink SQL> use testdb1;

Flink SQL>  create table t2(id int,name string);
[INFO] Table has been created.

Flink SQL> select * from t2;
[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.table.api.ValidationException: Table options do not contain an option key 'connector' for discovering a connector.

推荐答案

问题是Flink不知道在哪里找到或放置t2-它需要与某些数据源或接收器(例如文件)相关联,kafka主题或jdbc数据库.您还需要指定一种格式,以便可以对数据进行序列化/反序列化.例如:

The problem is that Flink doesn't know where to find or put t2 -- it needs to be associated with some data source or sink, such as a file, or kafka topic, or jdbc database. You also need to specify a format, so that the data can be serialized / deserialized. For example:

CREATE TABLE KafkaTable (
  `id` BIGINT,
  `name` STRING
) WITH (
  'connector' = 'kafka',
  'topic' = 'data',
  'properties.bootstrap.servers' = 'localhost:9092',
  'properties.group.id' = 'testGroup',
  'scan.startup.mode' = 'earliest-offset',
  'format' = 'csv'
)

请参阅 docs 您正在使用的特定连接器以获取更多信息.

See the docs for the specific connector you are using for more information.

在Hive的特定情况下,请参见蜂巢阅读&写.有一个示例设置用于写入Hive的表此处,它看起来像这样:

In the specific case of Hive, see Hive Read & Write. There's an example of setting up a table for writing to Hive here, which looks something like this:

SET table.sql-dialect=hive;
CREATE TABLE hive_table (
  id BIGINT,
  name STRING
) PARTITIONED BY (dt STRING, hr STRING) STORED AS parquet TBLPROPERTIES (
  'partition.time-extractor.timestamp-pattern'='$dt $hr:00:00',
  'sink.partition-commit.trigger'='partition-time',
  'sink.partition-commit.delay'='1 h',
  'sink.partition-commit.policy.kind'='metastore,success-file'
);

这篇关于表选项不包含选项键“连接器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 21:40