Reputation: 3
I have below json
{attribute_values=[{key=PO, values=[234234, 21]}, {key=POReceipt, values=[ABC]}]}
How i will define attribute_values Column?
currently I defined as String and getting error while inserting via Dataflow
"errorMessage": "{\n \"errors\" : [ {\n \"debugInfo\" : \"\",\n \"location\" : \"attribute_values\",\n \"message\" : \"Array specified for non-repeated field.\",\n \"reason\" : \"invalid\"\n } ],\n \"index\" : 0\n}",
"stacktrace": null
}
Upvotes: 0
Views: 477
Reputation: 941
You have a BQ table with column attribute_value with datatype string and now you want to change the datatype of that column. There are 2 options you can choose from
Please check this documentation Changing a column data type for more details
Upvotes: 0
Reputation: 3632
How I will define attribute_values Column?
You can create your table as follow:
-- create table
CREATE TABLE IF NOT EXISTS `projectId.datasetId.tableName`
(
attribute_values STRUCT <key String, values ARRAY<STRING>>
)
You can use the below INSERT
sql example to test how to populate your table
INSERT INTO
`projectId.datasetId.tableName` (attribute_values)
values (
STRUCT <key String, values ARRAY<STRING>>('PO', ['234234', '21'])
);
INSERT INTO
`projectId.datasetId.tableName` (attribute_values)
values (
STRUCT <key String, values ARRAY<STRING>>('POReceipt', ['ABC'])
);
To do this via code you can check this answer for more details.
Upvotes: 1