表选项不包含选项键“连接器" [英] Table options do not contain an option key 'connector'
问题描述
我想使用 flink sql 客户端创建一个 hive 表.
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'
)
请参阅文档您正在使用的特定连接器以获取更多信息.
See the docs for the specific connector you are using for more information.
Hive 的具体情况,见 Hive Read &写.有一个设置用于写入 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'
);
这篇关于表选项不包含选项键“连接器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!