简体   繁体   English

KSQL 创建表作为选择

[英]KSQL create table as select

CREATE TABLE AS SELECT can be done only with a grouping, but how then in the Base to organize a table (you need a simple table without aggregations / groupings) in order to supplement another stream with data? CREATE TABLE AS SELECT 只能通过分组来完成,但是如何在 Base 中组织一个表(您需要一个没有聚合/分组的简单表)以便用数据补充另一个流? As an example: There is a stream A with fields (product, city_id).举个例子:有一个带有字段(产品,city_id)的流 A。 We need a table (or something else) with fields (city_id, city_name) which is replenished by another thread.我们需要一个带有字段(city_id,city_name)的表(或其他东西),由另一个线程补充。

And there is a stream that connects complements stream A with the name from the table through.并且有一个流将补码流 A 与表中的名称连接起来。

How can you organize data enrichment using an external directory?如何使用外部目录组织数据扩充?

You can use the LATEST_BY_OFFSET aggregation to build a table of data in this way.您可以使用LATEST_BY_OFFSET聚合以这种方式构建数据表。

CREATE STREAM source_city_data 
  WITH (KAFKA_TOPIC='source_city_data', FORMAT='AVRO');

CREATE TABLE city_data AS 
  SELECT city_id, LATEST_BY_OFFSET(city_name) AS city_name 
  FROM source_city_data;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM