使用BQ命令行更改配置configuration.load.quote

时间:2014-09-14 03:05:36

标签: google-bigquery

我想知道如何使用BQ命令行工具我可以更改BigQuery API作业的配置。例如,我想从命令行工具更改configuration.load.quote属性。有什么办法吗?我需要这个来加载一个带有字段双引号(“)的表。

1 个答案:

答案 0 :(得分:6)

创建作业后无法修改作业,但我猜你想要的是在创建作业时设置报价属性。

在大多数情况下,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: '')