将JSON数据加载到BigQuery表中

将JSON数据加载到BigQuery表中,json,google-bigquery,Json,Google Bigquery,我试图通过以下方式将简单JSON数据加载到BigQuery表中: $bq加载\ --阿皮洛格\ --source\u format=换行符\u分隔符\u JSON\ my_dataset.my_表\ ./input.json./schema.json 但会收到以下错误消息: Upload complete. Waiting on bqjob_xxxx_xxx ... (3s) Current status: DONE BigQuery error in load operation: Erro

我试图通过以下方式将简单JSON数据加载到BigQuery表中:

$bq加载\
--阿皮洛格\
--source\u format=换行符\u分隔符\u JSON\
my_dataset.my_表\
./input.json./schema.json
但会收到以下错误消息:

Upload complete.
Waiting on bqjob_xxxx_xxx ... (3s) Current status: DONE
BigQuery error in load operation: Error processing job 'my_project_id:bqjob_xxxx_xxx': CSV table encountered too many errors, giving up. Rows: 1; errors: 1.
Failure details:
- file-00000000: Error detected while parsing row starting at
position: 0. Error: Data between close double quote (") and field
separator.
它抱怨一些CSV错误,但我正在尝试加载JSON(
--source\u format=NEWLINE\u DELIMITED\u JSON

My
input.json
包含以下数据:

{“domain”:“stackoverflow.com”,“key”:“hello”,“value”:“world”}
我的
schema.json
如下所示:

[
{
“名称”:“域”,
“类型”:“字符串”,
“模式”:“可为空”
},
{
“名称”:“密钥”,
“类型”:“字符串”,
“模式”:“可为空”
},
{
“名称”:“值”,
“类型”:“字符串”,
“模式”:“可为空”
}
]
bq
2.0.25版:

$ gcloud version | grep ^bq
bq 2.0.25
BQ司令部说:

USAGE: bq.py [--global_flags] <command> [--command_flags] [args]
命令\u标志为布尔值:

--[no]replace
或者,它们接受的参数必须遵循以下标志:

--source_format NEWLINE_DELIMITED_JSON
另外,不要混合使用全局标志和命令标志:apilog是一个全局标志。 我会将您的命令改写为:

$ bq --apilog load \
    --source_format NEWLINE_DELIMITED_JSON \
    my_dataset.my_table \
    ./input.json ./schema.json
BQ司令部说:

USAGE: bq.py [--global_flags] <command> [--command_flags] [args]
命令\u标志为布尔值:

--[no]replace
或者,它们接受的参数必须遵循以下标志:

--source_format NEWLINE_DELIMITED_JSON
另外,不要混合使用全局标志和命令标志:apilog是一个全局标志。 我会将您的命令改写为:

$ bq --apilog load \
    --source_format NEWLINE_DELIMITED_JSON \
    my_dataset.my_table \
    ./input.json ./schema.json

这里的问题是标志
apilog
需要一个字符串作为输入。此命令应适用于您:

bq load \
    --apilog '' \
    --source_format=NEWLINE_DELIMITED_JSON \
    my_dataset.my_table \
    ./input.json ./schema.json

空字符串将输出发送到
stdout
。如果要将日志保存到本地文件,则只需发送一个非空字符串,例如
--apilog'localfile\u name'

这里的问题是标记
apilog
需要一个字符串作为输入。此命令应适用于您:

bq load \
    --apilog '' \
    --source_format=NEWLINE_DELIMITED_JSON \
    my_dataset.my_table \
    ./input.json ./schema.json
空字符串将输出发送到
stdout
。如果要将日志保存到本地文件,则只需发送一个非空字符串,例如
--apilog'localfile\u name'

最好使用
bq--apilog-load…
bq--apilog'load…
因为没有参数
--apilog
使用
load
作为参数。最好使用
bq--apilog load…
bq--apilog load…
因为没有参数参数
——apilog
使用
load
作为其参数。