您可以在 table 中批量导入带有对象列数组的 crateDB 吗?
Can you bulk import in crateDB in a table with an array of objects column?
所以我 运行 CrateDB 3.3.3 我有一个 table 它有一列对象数组类型
CREATE TABLE IF NOT EXISTS "doc"."testarray" (
"id" INTEGER,
"myarraycol" ARRAY(OBJECT (DYNAMIC) AS (
"avg" DOUBLE,
"eventconditiondefid" INTEGER,
"max" DOUBLE,
"min" DOUBLE
))
)
我已经知道怎么插入一行了
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}]);
但是,在我的应用程序中,我通过 HTTP 端点将数据批量插入 CrateDB。
https://crate.io/docs/crate/reference/en/latest/interfaces/http.html
我让它适用于常规 tables,但无法使其适用于具有一列对象数组的 table。谁能告诉我如何使批量插入与这些类型的列一起使用?我似乎找不到任何示例或文档。
{ "stmt":"INSERT INTO testarray ( id, myarraycol) VALUES ( ?, ?) ","bulk_args":[[1,[{"min"=0.616523,"max" = 1.10974,"Avg" = 0.874692,"EventConditionDefId" = 505}]]]}
(上面的批量插入代码失败,它returns一个(400)错误的请求)
问题是JSON应该是这样的:
{ "stmt":"INSERT INTO testarray (id, myarraycol) VALUES (?,?) ","bulk_args":[[1,[{"min":0.616523,"max" : 1.10974,"Avg" : 0.874692,"EventConditionDefId" : 505}]]]}
所以我 运行 CrateDB 3.3.3 我有一个 table 它有一列对象数组类型
CREATE TABLE IF NOT EXISTS "doc"."testarray" (
"id" INTEGER,
"myarraycol" ARRAY(OBJECT (DYNAMIC) AS (
"avg" DOUBLE,
"eventconditiondefid" INTEGER,
"max" DOUBLE,
"min" DOUBLE
))
)
我已经知道怎么插入一行了
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}]);
但是,在我的应用程序中,我通过 HTTP 端点将数据批量插入 CrateDB。
https://crate.io/docs/crate/reference/en/latest/interfaces/http.html
我让它适用于常规 tables,但无法使其适用于具有一列对象数组的 table。谁能告诉我如何使批量插入与这些类型的列一起使用?我似乎找不到任何示例或文档。
{ "stmt":"INSERT INTO testarray ( id, myarraycol) VALUES ( ?, ?) ","bulk_args":[[1,[{"min"=0.616523,"max" = 1.10974,"Avg" = 0.874692,"EventConditionDefId" = 505}]]]}
(上面的批量插入代码失败,它returns一个(400)错误的请求)
问题是JSON应该是这样的:
{ "stmt":"INSERT INTO testarray (id, myarraycol) VALUES (?,?) ","bulk_args":[[1,[{"min":0.616523,"max" : 1.10974,"Avg" : 0.874692,"EventConditionDefId" : 505}]]]}