我正在尝试使用补丁通过ruby Google API客户端更新现有表的架构。
以下是代码:
def updateTable(client, bq, schema,dataset,table)
result = client.execute(:api_method => bq.tables.patch,
:parameters => {'projectId' => PROJECT, 'datasetId' => dataset, 'tableId' => table},
:body_object => {
"tableReference" => {
"datasetId" => dataset,
"projectId" => "mydataset-1",
"tableId" => table
},
"schema" => schema
}
)
puts result.body
端
这是我得到的错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid schema update. Field a_b_testing_group is missing in new schema"
}
],
"code": 400,
"message": "Invalid schema update. Field a_b_testing_group is missing in new schema"
} }
我会感激任何指示和建议。 谢谢,
以下是示例模式:
{ "fields" : [
{ "fields" : [
{ "mode" : "NULLABLE",
"name" : "time",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "attempts",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "mode",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "distinct_id",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "waited",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "party_size",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "version",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "region",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "reachability",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "device",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "_os",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "a_b_testing_group",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "item_name",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "price",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "contestant",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "mp_country_code",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "_city",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "_region",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "source",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "label",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "sku",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "balance__soft_",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "balance__hard_",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "price__soft_",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "free",
"type" : "BOOLEAN"
},
{ "mode" : "NULLABLE",
"name" : "price__hard_",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "magical_damage_dealt",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "magical_damage_dealt__players_",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "player_kills",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "damage_taken",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "duration",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "items_consumed",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "magical_damage_taken",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "physical_damage_dealt__players_",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "disconnects",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "items_sold",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "physical_damage_taken",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "healing_done",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "matches",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "relic",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "assists",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "largest_kill_streak",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "bots",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "gold",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "largest_multi_kill",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "ping",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "team",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "tribute_kills",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "connects",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "deaths",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "shrine_captures",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "spawns",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "items_bought",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "physical_damage_dealt",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "abandoned",
"type" : "BOOLEAN"
},
{ "mode" : "NULLABLE",
"name" : "damage_dealt",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "damage_dealt__players_",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "level",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "party_muted",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "quests_completed",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "tower_kills",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "victorious",
"type" : "BOOLEAN"
},
{ "mode" : "NULLABLE",
"name" : "name",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "response",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "type",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "currency_type",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "state",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "last_quest",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "product",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "amount",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "platform",
"type" : "STRING"
},
{ "mode" : "NULLABLE",
"name" : "newbie",
"type" : "BOOLEAN"
},
{ "mode" : "NULLABLE",
"name" : "campaign_id",
"type" : "FLOAT"
},
{ "mode" : "NULLABLE",
"name" : "delivery_id",
"type" : "FLOAT"
}
],
"mode" : "NULLABLE",
"name" : "properties",
"type" : "RECORD"
},
{ "mode" : "NULLABLE",
"name" : "event",
"type" : "STRING"
}
] }
答案 0 :(得分:0)
BigQuery支持向现有表添加列,但不删除现有表。
为防止显示错误,在修补表架构时,始终在新架构中包含现有列,并仅向其添加列。