2012-09-27 2 views
2

큰 쿼리 명령 줄 도구를 사용하여 json 파일 (csv 제외)에서 데이터를로드 할 수 있습니까? GUI를 사용하여 간단한 json 파일을로드 할 수 있지만 명령 줄에 csv가 있다고 가정하고 json을 지정하는 방법에 대한 설명서가 표시되지 않습니다. {: "값" "앙"}biq 쿼리 명령 줄에서 json 파일로드

스키마 안부와 함께 :이 JSON 형식의 데이터 로딩을 지원하지 않습니다

+0

추가 지원하여 다른 BQ로드 변종을 찾을 수 있습니다)

bq load [--source_format=NEWLINE_DELIMITED_JSON] [--project_id=your_project_id] destination_data_set.destination_table data_source_uri table_schema bq load --project_id=my_project_bq dataset_name.bq_table_name gs://bucket_name/json_file_name.json path_to_schema_in_your_machine 

5입니다. http://googledledvelopers.blogspot.com/2012/10/got-big-json-bigquery-expands-data.html – mdahlman

+0

그게 좋습니다! 그러나 9/11 이후에 api가 수정 된 것처럼 보이지는 않습니다. 현재 버전 2.0.9는 source_format 플래그가 아니라는 것을 알려줍니다. –

+0

한 번에 하나의 파티션을로드하는 데 제한이 있습니까? 모든 것을로드하는 래퍼 스크립트가 필요합니까? – mel

답변

0

STRING

여기에 내가

를 사용하고 간단한 JSON 파일입니다. 버전 2.0.12의로

USAGE: bq [--global_flags] <command> [--command_flags] [args] 


load  Perform a load operation of source into destination_table. 

    Usage: 
    load <destination_table> <source> [<schema>] 

    The <destination_table> is the fully-qualified table name of table to create, or append to if the table already exists. 

    The <source> argument can be a path to a single local file, or a comma-separated list of URIs. 

    The <schema> argument should be either the name of a JSON file or a text schema. This schema should be omitted if the table already has one. 

    In the case that the schema is provided in text form, it should be a comma-separated list of entries of the form name[:type], where type will default 
    to string if not specified. 

    In the case that <schema> is a filename, it should contain a single array object, each entry of which should be an object with properties 'name', 
    'type', and (optionally) 'mode'. See the online documentation for more detail: 
    https://code.google.com/apis/bigquery/docs/uploading.html#createtable 

    Note: the case of a single-entry schema with no type specified is 
    ambiguous; one can use name:string to force interpretation as a 
    text schema. 

    Examples: 
    bq load ds.new_tbl ./info.csv ./info_schema.json 
    bq load ds.new_tbl gs://mybucket/info.csv ./info_schema.json 
    bq load ds.small gs://mybucket/small.csv name:integer,value:string 
    bq load ds.small gs://mybucket/small.csv field1,field2,field3 

    Arguments: 
    destination_table: Destination table name. 
    source: Name of local file to import, or a comma-separated list of 
    URI paths to data to import. 
    schema: Either a text schema or JSON file, as above. 

    Flags for load: 

/usr/local/bin/bq: 
    --[no]allow_quoted_newlines: Whether to allow quoted newlines in CSV import data. 
    -E,--encoding: <UTF-8|ISO-8859-1>: The character encoding used by the input file. Options include: 
    ISO-8859-1 (also known as Latin-1) 
    UTF-8 
    -F,--field_delimiter: The character that indicates the boundary between columns in the input file. "\t" and "tab" are accepted names for tab. 
    --max_bad_records: Maximum number of bad records allowed before the entire job fails. 
    (default: '0') 
    (an integer) 
    --[no]replace: If true erase existing contents before loading new data. 
    (default: 'false') 
    --schema: Either a filename or a comma-separated list of fields in the form name[:type]. 
    --skip_leading_rows: The number of rows at the beginning of the source file to skip. 
    (an integer) 

gflags: 
    --flagfile: Insert flag definitions from the given file into the command line. 
    (default: '') 
    --undefok: comma-separated list of flag names that it is okay to specify on the command line even if the program does not define a flag with that name. 
    IMPORTANT: flags in this list that have arguments MUST use the --flag=value format. 
    (default: '') 
+0

응답 해 주셔서 감사합니다. GUI가 지원하는 이유를 알고 있습니까? GUI가 JSON을 CSV로 변환합니까? 100MB 파일 (Ui 파일 크기 제한)을 변환해야한다면 상당히 성능이 좋은 것 같습니다. –

+0

GUI가 변환 작업을 수행합니다. 파일 크기 제한은 100MB가 아닌 4GB입니까? – Charles

+0

흠, 나는 GUI 파일 제한이 100MB 였지만 지금은 찾을 수 없다는 것을 맹세 했었습니다. –

6

, BQ 줄 바꿈으로 구분 된 JSON 파일을 업로드 할 수 않습니다 여기에 최신 BQ 버전 2.0.9로 load 명령에 대한 문서 (bq help load)입니다. 다음은 작업을 수행하는 명령의 예입니다.

bq load --source_format NEWLINE_DELIMITED_JSON datasetName.tableName data.json schema.json 

위에서 언급 한 것처럼 "bq help load"는 모든 세부 사항을 제공합니다.

1

1) 네, 당신이 문서는 here

2)입니다 수 있습니다. 3 단계 : 문서에 표 업로드하기로 이동하십시오.

3) --source_format 플래그를 사용하여 bs에게 csv가 아닌 JSON 파일을 업로드한다고 알려야합니다.

4) 전체의 커멘드를 구조 당신은 오늘 발표 된 JSON에 대한

bq help load