首页 > 解决方案 > “表选项不包含选项键'连接器'”的另一种情况

问题描述

我已阅读链接表选项不包含选项键“连接器”

它说我们应该设置格式。

但我的场景是 datagen->hive。这是我完成的例子(现在错了)

drop table if exists datagen;
CREATE TABLE datagen (
 f_sequence INT,
 f_random INT,
 f_random_str STRING,
 ts AS localtimestamp,
 WATERMARK FOR ts AS ts
) WITH (
 'connector' = 'datagen',

 -- optional options --

 'rows-per-second'='5',

 'fields.f_sequence.kind'='sequence',
 'fields.f_sequence.start'='1',
 'fields.f_sequence.end'='50',-- 这个地方限制了一共会产生的条数

 'fields.f_random.min'='1',
 'fields.f_random.max'='50',

 'fields.f_random_str.length'='10'
);

SET table.sql-dialect=hive;
drop table if exists hive_table;

CREATE TABLE hive_table (
  f_sequence INT,
  f_random INT,
  f_random_str STRING
) PARTITIONED BY (dt STRING, hr STRING, mi STRING) STORED AS parquet TBLPROPERTIES (
  'partition.time-extractor.timestamp-pattern'='$dt $hr:$mi:00',
  'sink.partition-commit.trigger'='partition-time',
  'sink.partition-commit.delay'='1 min',
  'sink.partition-commit.policy.kind'='metastore,success-file'
);


Flink SQL> insert into hive_table select f_sequence,f_random,f_random_str ,DATE_FORMAT(ts, 'yyyy-MM-dd'), DATE_FORMAT(ts, 'HH') ,DATE_FORMAT(ts, 'mm') from datagen;
[INFO] Submitting SQL update statement to the cluster...
[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.

上述链接的解决方案是否适合这种情况?

需要你的帮助,谢谢~!

标签: apache-flinkflink-sql

解决方案


SET table.sql-dialect=default;在调用前使用insert into hive_table...,使用 datagen 连接器的语句insert into hive_table...不支持 hive 方言。


推荐阅读