如何将整个json写入表中

Viewed 11

doris 版本3.0.8

  1. 使用routine load消费kafka到表中
  2. kafka数据为json
  3. 表结构,jsonstr用来存储整个json消息
    (
    topicname varchar(500) NULL DEFAULT 'topic_name', 
    jsonstr text NULL,
    data_day datev2 NULL DEFAULT CURRENT_DATE,
    input_time datetimev2 NULL DEFAULT CURRENT_TIMESTAMP
    )
    
  4. routine load参数
    COLUMNS(
        jsonstr
     )
     PROPERTIES(
        "desired_concurrent_number" = "2",
        "max_batch_interval" = "20",
        "format" = "json",
        "jsonpaths" = "[\"$\"]",
        "strip_outer_array" = "false",
        "strict_mode" = "false"
     )
    
  5. kafka消息:{"text":"this is a test text data"}
  6. 写到表里变成了[{"text":"this is a test text data"}]

配置该如何优化,将这个[]去掉

  • 补充信息:之前是使用format=CSV,由于部分kafka没有进行压缩存在\t \n的格式符,\n导致一条消息中的一个json写入表后,被拆分成了多行,文档中查到routine load不支持修改默认换行符,所以改用了format=json,但是出现了这种问题
0 Answers