Table 选项不包含选项键 'connector'

Table options do not contain an option key 'connector'

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

我可以成功创建 table t2,但是当我查询 t2 时,它会报错

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

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

请问这里是什么问题。谢谢!

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 数据库.您还需要指定一种格式,以便可以对数据进行序列化/反序列化。例如:

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

在 Hive 的特定情况下,请参阅 Hive Read & Write. There's an example of setting up a table for writing to Hive here,它看起来像这样:

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'
);