简体   繁体   中英

Can you bulk import in crateDB in a table with an array of objects column?

So I run CrateDB 3.3.3 and I have a table which has a column of type array of objects

CREATE TABLE IF NOT EXISTS "doc"."testarray" (
"id" INTEGER,
"myarraycol" ARRAY(OBJECT (DYNAMIC) AS (
  "avg" DOUBLE,
  "eventconditiondefid" INTEGER,
  "max" DOUBLE,
  "min" DOUBLE
))
)

I already know how to insert one row in it

insert into testarray (id, myarraycol) values (2, [{"min"=2,"max"=3,"avg"=0.5,"eventconditiondefid"=123},{"min"=0,"max"=1,"avg"=0.5,"eventconditiondefid"=456}]);

However, in my application, I bulk insert data into CrateDB via the HTTP endpoint.

https://crate.io/docs/crate/reference/en/latest/interfaces/http.html

I have it working for regular tables, but cannot make it work for a table with a column of array of objects. Can anyone tell me how I can make the bulk insert work with those types of columns? I can't seem to find any examples or documentations on it.

{ "stmt":"INSERT INTO testarray (  id, myarraycol) VALUES (  ?,   ?) ","bulk_args":[[1,[{"min"=0.616523,"max" = 1.10974,"Avg" = 0.874692,"EventConditionDefId" = 505}]]]}

(The above bulk insert code fails, it returns a (400) bad request)

问题是JSON,它应该如下所示:

{ "stmt":"INSERT INTO testarray (id, myarraycol) VALUES (?,?) ","bulk_args":[[1,[{"min":0.616523,"max" : 1.10974,"Avg" : 0.874692,"EventConditionDefId" : 505}]]]}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM