我的表'column_defn'具有以下架构。键是column_name,database_name和table_name
column_name STRING(130) NOT NULL
database_name STRING(150) NOT NULL
table_name STRING(130) NOT NULL
column_description STRING(1000) NOT NULL
我正在尝试使用以下REST请求删除行
{
"session":"xxxxxxxxx"
"singleUseTransaction": {
"readWrite": {}
},
"mutations": [
{
"delete": {
"table": "column_defn",
"keySet": {
"keys": [
[
{
"column_name": "testd"
},
{
"table_name": "test atbd"
},
{
"database_name": "ASDFDFS"
}
]
]
}
}
}
]
}
但我一直收到以下错误。任何关于上述请求中哪里出错的想法
{
"error": {
"code": 400,
"message": "Invalid value for column database_name in table column_defn: Expected STRING.",
"status": "FAILED_PRECONDITION"
}
}
更新:以下请求似乎成功。至少它返回了成功代码200和commitTimestamp。但是,该行未被删除
{
"singleUseTransaction": {
"readWrite": {}
},
"mutations": [
{
"delete": {
"table": "column_defn",
"keySet": {
"keys": [
[
"testd",
"dsafd",
"test atbd"
]
]
}
}
}
]
}
答案 0 :(得分:2)
keys
应该包含一个数组数组。在外部数组中,您尝试删除的每一行都有一个条目。每个内部数组都是定义单行的键值的有序列表( order重要)。所以在你的例子中,你想要:
"keys": [["testd","ASDFDFS","test atbd"]]
请注意,原始问题与表中键的真实顺序不一致。上面的答案假设主键定义如下:
PRIMARY KEY(column_name,database_name,table_name)