Updated on 2024-12-13 GMT+08:00

Optimizing FlinkSQL JSON_VALUE Performance

This section applies to MRS 3.5.0 or later.

Scenarios

When the built-in JSON_VALUE function parses multiple fields of a JSON item, the parsing result of the previous JSON item is reused to improve the performance.

How to Use

When you configure a Flink job, set table.optimizing.json-value-optimization to true on the Flink job development page of the FlinkServer web UI to optimize the performance of the JSON_VALUE function. For details, see Creating a FlinkServer Job.

The following is an example SQL statement:
create table kafkaSource (
    msgValue STRING
) with (
    'connector' = 'kafka'
    ,'topic' = 'topic-1'
    ,'properties.bootstrap.servers' ='Service IP address of the Kafka Broker instance:Kafka port'
    ,'properties.group.id' = 'group-1'
    ,'value.format' = 'raw'
    ,'scan.startup.mode' = 'group-offsets'
    ,'properties.auto.offset.reset' = 'earliest'
    ,'value.fields-include' = 'EXCEPT_KEY'
);
create table print (
    id STRING,
    name STRING
) with (
      'connector' = 'print'
);
INSERT INTO print
SELECT
    JSON_VAL(msgValue, '$.id'),
    JSON_VAL(msgValue, '$.name')
from kafkaSource;