Giriş
CREATE TABLE ile yaratılan tablo her key için en son değeri gösterir.
CREATE TABLE Söz Dizimi
Şöyledir
CREATE TABLE tablename as SELECT QUERY
Normal CREATE TABLE Söz Dizimi şöyle. Yani SELECT QUERY kısmı yok
CREATE TABLE customers ( id INT PRIMARY KEY, first_name VARCHAR, last_name VARCHAR, gender VARCHAR, country VARCHAR ) WITH ( kafka_topic='customers', partitions=1, value_format='avro' );
SELECT QUERY
SELECT QUERY içinde
CAST
COLLECT_LIST
COUNT
GEO_DISTANCE
GROUP BY
LATEST_BY_OFFSET
ROUND
SUBSTRING
gibi metodlar kullanılabilir
LATEST_BY_OFFSET
Açıklaması şöyle
The LATEST_BY_OFFSET aggregation allows you to select any column and retains only the last value it receives, where “last” is in terms of offsets.
Örnek
Şöyle yaparız
CREATE STREAM customers WITH ( kafka_topic = 'mysql.customers_db.customers', value_format = 'avro' ); CREATE TABLE customers_meta AS SELECT id, latest_by_offset(first_name) AS first_name, latest_by_offset(last_name) AS last_name, latest_by_offset(gender) AS gender, latest_by_offset(country) AS country FROM customers GROUP BY id EMIT CHANGES;
No comments:
Post a Comment