2014-09-14 4 views
2

Я хочу знать, как использовать инструмент командной строки BQ. Я могу изменить конфигурацию задания BigQuery API. Например, я хочу изменить свойство configuration.load.quote из инструмента командной строки. Есть ли какой-то способ. Мне это нужно, чтобы загрузить таблицу с полем двойными кавычками (") внутри.Использование конфигурации конфигурации командной строки BQ configuration.load.quote

ответ

4

Вы не можете изменить работу, как только он будет создан, но я предполагаю, что вы хотите установить котировки свойство при создании задания.

в большинстве случаев, bq help <command> получите, что вам нужно. Вот вывод bq help load. Как вы можете видеть, вы просто должны указать --quote="'" после команды, но перед аргументами.

$ bq help load 
Python script for interacting with BigQuery. 


USAGE: bq.py [--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://developers.google.com/bigquery/preparing-data-for-bigquery 

     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: 

/home/David/google-cloud-sdk/platform/bq/bq.py: 
    --[no]allow_jagged_rows: Whether to allow missing trailing optional columns in 
    CSV import data. 
    --[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. 
    --[no]ignore_unknown_values: Whether to allow and ignore extra, unrecognized 
    values in CSV or JSON import data. 
    --max_bad_records: Maximum number of bad records allowed before the entire job 
    fails. 
    (default: '0') 
    (an integer) 
    --quote: Quote character to use to enclose records. Default is ". To indicate 
    no quote character at all, use an empty string. 
    --[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) 
    --source_format: <CSV|NEWLINE_DELIMITED_JSON|DATASTORE_BACKUP>: Format of 
    source data. Options include: 
    CSV 
    NEWLINE_DELIMITED_JSON 
    DATASTORE_BACKUP 

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

большое спасибо Дэвиду. Он работал для меня. – user1929927

+0

Я рад это слышать. На Stack OVerflow принято принимать ответ , так что человек, который отвечает, получает очки, и люди, которые посещают вопрос, знают, что ответ сработал. Если вы можете это сделать, это здорово. – David

+0

Спасибо, Дэвид. Мой текущий момент не позволяет мне проголосовать за этот ответ. Большое спасибо, кстати. – user1929927

Смежные вопросы