Skip to content

StreamLoad

JSON

采用 curl 方式导入:

shell
curl --location-trusted -u root:123456 -H "format: json" -H "read_json_by_line: true" -H "Expect: 100-continue" \
-H "columns: vehicle_id,terminal_code,terminal_id,gpsdate,gpstime,recvtime,serverid,location_mode,speed,av,alt,dir,satellite,lng,lat,glng_xz,glat_xz,blng_xz,blat_xz,electricity,gsm,lbs,state,today_distance,distance,last_run_time,alarm,alarmsoft,alarm1078,duelectricity, param, wifi, accuracy, electnum,temp1,temp2,temp3,temp4, humidity1, humidity2, humidity3, humidity4, oil, oil2, oil3,  oil4, vol1,  vol2, vol3, vol4, roadlevel, maxspeed,logger_speed,alarmcustid, posinfo, identityno, weight,weight2,zhongliang, zhongliang2, alarm2, alarmsoft2, clientid" \
-T guiji-seg.1751598200458.json http://172.18.0.143:8030/api/exlive3/video_gps/_stream_load

说明:

  • format: json 导入 JSON 格式;
  • line_delimiter: 每行的分隔符;一般为:\n;
  • read_json_by_line:读取JSON格式,每行一条;
  • strip_outer_array:true: 读取 JSON Array格式;
  • max_filter_ratio: 最大允许的错误比例;
  • label: import_load_name: 指定 import 的任务名称;

TXT

建表语句:

sql
CREATE TABLE test_bitmap(
    typ_id     BIGINT                NULL   COMMENT "ID",
    hou        VARCHAR(10)           NULL   COMMENT "one",
    arr        BITMAP  BITMAP_UNION  NOT NULL   COMMENT "two"
)
AGGREGATE KEY(typ_id,hou)
DISTRIBUTED BY HASH(typ_id,hou) BUCKETS 1
PROPERTIES (
  "replication_num" = "1"
);

导入文本数据

shell
curl --location-trusted -u root:123456 \
    -H "column_separator:|" \
    -H "Expect: 100-continue" \
    -H "columns:typ_id,hou,arr,arr=to_bitmap(arr)" \
    -T test_bitmap.txt \
    -XPUT http://172.18.0.143:8030/api/exlive3/test_bitmap/_stream_load

说明:

  • column_separator:, 字段间分隔符;
  • columns: col1,col2,col3 多个字段;
  • max_filter_ratio: 最大允许的错误比例;
  • label: import_load_name: 指定 import 的任务名称;

数据导出

基于查询条件的导出:

sql
SELECT recvtime, vehicle_id,lng,lat,posinfo from exlive3.video_gps where gpsdate = CURDATE() limit 1000
INTO OUTFILE "file:///root/export_select"
FORMAT AS PARQUET;