How to read null value from Kafka using flink sql

25 views Asked by At

I have a table defined as

CREATE TABLE kafka_table (
  field1 INT,
  field2 STRING,
  field3 DOUBLE
) WITH (
  'connector' = 'kafka',
  'topic' = 'your_topic_name',
  'properties.bootstrap.servers' = 'your_bootstrap_servers',
  'properties.group.id' = 'your_consumer_group_id',
  'format' = 'json'
);

I want to read a Kafka message with null value. The whole body is null.

The above code currently skip reading the message. I am using flink 1.18

1

There are 1 answers

0
Niko On

You should see json format options.

Probably you should change json.map-null-key.mode By default it's in 'FAIL' state (will throw exception when encountering map with null key.)

And you can set json.map-null-key.literal if you want to have string 'null' or other string like 'n/a'...