Export and load statements in GoogleSQL

EXPORT DATA statement

The EXPORT DATA statement exports the results of a query to an external storage location. The storage location must be Cloud Storage, Bigtable, or Amazon Simple Storage Service (Amazon S3). For more information, see Exporting table data.

Syntax

EXPORT DATA
[WITH CONNECTION connection_name]
OPTIONS (export_option_list) AS
query_statement

Arguments

  • connection_name: Specifies a connection that has credentials for accessing the external data. Specify the connection name in the form PROJECT_ID.LOCATION.CONNECTION_ID. If the project ID or location contains a dash, enclose the connection name in backticks (`). Connections are not supported when exporting to Bigtable.

  • export_option_list: Specifies a list of options for the export operation, including the URI of the destination. For more information, see either the Cloud Storage and Amazon Simple Storage Service (Amazon S3) export option list or the Bigtable export option list.

  • query_statement: A SQL query. The query result is exported to the external destination. The query can't reference metatables, including INFORMATION_SCHEMA views, system tables, or wildcard tables.

Export to Cloud Storage

You can export to Cloud Storage in Avro, CSV, JSON, and Parquet formats.

Use the format option to specify the format of the exported data. The following limitations apply:

  • You cannot export nested and repeated data in CSV format.
  • If you export data in JSON format, INT64 data types are encoded as JSON strings to preserve 64-bit precision.

Cloud Storage and Amazon S3 export option list

The option list specifies options for the export operation. Specify the option list in the following format: NAME=VALUE, ...

The uri and format options are required.

Options
compression

STRING

Specifies a compression format. If not specified, the exported files are uncompressed. Supported values include: GZIP, DEFLATE, SNAPPY.

field_delimiter

STRING

The delimiter used to separate fields. Default: ',' (comma).

Applies to: CSV.

format

STRING

Required. The format of the exported data. Supported values include: