StreamLoad
建表:
CREATE TABLE test
(
col1 int(11) NULL COMMENT “”,
col2 int(11) NULL COMMENT “”
) ENGINE=OLAP
DUPLICATE KEY( col1 , col2 )
COMMENT “OLAP”
DISTRIBUTED BY HASH( col1 ) BUCKETS 10
PROPERTIES (
“replication_num” = “1”,
“in_memory” = “false”,
“storage_format” = “DEFAULT”
);
CREATE TABLE testjson (
category varchar(512) NULL COMMENT “”,
author varchar(512) NULL COMMENT “”,
title varchar(512) NULL COMMENT “”,
price double NULL COMMENT “”
) ENGINE=OLAP
DUPLICATE KEY(category, author)
COMMENT “OLAP”
DISTRIBUTED BY HASH(category) BUCKETS 10
PROPERTIES (
“replication_num” = “1”,
“in_memory” = “false”,
“storage_format” = “DEFAULT”
);
测试场景:
1.导入本地csv文件:
数据:

curl --location-trusted -u root -T datatest.csv -H “label:123” http://xxxx:8012/api/qcy/test/_stream_load

导入failed查看错误url:

指定分隔符重新导入:
curl --location-trusted -u root -T datatest.csv -H “column_separator:,” -H “label:123” http://xxxx:8012/api/qcy/test/_stream_load

2.只导入col2列大于10的数据
curl --location-trusted -u root -T datatest.csv -H “column_separator:,” -H"where:col2>10" -H “label:1” http://xxxx:8012/api/qcy/test/_stream_load
预期导入21条,导入成功。

3.指定列名导入
curl --location-trusted -u root -T datatest.csv -H “column_separator:,” -H"columns:col2,col1" -H"where:col1>10" -H “label:2” http://xxxx:8012/api/qcy/test/_stream_load

4.导入json数据
json数据:

curl --location-trusted -u root -H “strip_outer_array: true” -H “columns: category, price, author, title” -H “label:6” -H “jsonpaths: [”$.category","$.price","$.author", “$.title”]" -H “format: json” -T test.json http://xxxx:8012/api/qcy/testjson/_stream_load


5.指定json根节点导入
json数据:

curl --location-trusted -u root -H “strip_outer_array: true” -H “columns: category, price, author” -H “json_root: $.RECORDS” -H “label:4” -H “jsonpaths: [”$.category","$.price","$.author"]" -H “format: json” -T test.json http://xxxx:8012/api/qcy/testjson/_stream_load

