0
CREATE TABLE user_log (
    data ROW(id String,user_id String,class_id String)
) WITH (
    'connector.type' = 'kafka',
    ...
);

INSERT INTO sink
SELECT * FROM user_log as tab,
LATERAL TABLE(splitUdtf(tab.data)) AS T(a,b,c);

UDTF Code:

public void eval(Row data) {...}

Can the eval method only pass Row type parameters? I want to get the key of Row in SQL,such as id,user_id,class_id,But the key of Row in java is index (such as 0,1,2).How do i do it? Thank you!

Zheng
  • 21
  • 2

1 Answers1

0

Is your sql able to directly convert kafka data to table Row? Maybe not . Row is the type at the DataStream level, not the type in TableAPI&SQL.

If the data you received from kafka is in json format, you can use the DDL statement in fllink sql or use the Connector API to directly extract the fields in json, as long as your json is in key-value format.

lec_ssmi
  • 52
  • 5