Exporting Data
COPY TO
<file path>
must be a path on the server. This command exports the results of any SELECT statement to the file. There is a special mode when <file path>
is empty. In that case, the server automatically generates a file in <HEAVY.AI Directory>/export
that is the client session id with the suffix .txt
.
Available properties in the optional WITH clause are described in the following table.
Parameter | Description | Default Value |
| Define how to export with arrays that have null elements:
Applies only to GeoJSON and GeoJSONL files. |
|
| A single-character string for the delimiter between column values; most commonly:
Other delimiters include Applies to only CSV and tab-delimited files. Note: HEAVY.AI does not use file extensions to determine the delimiter. |
|
| A single-character string for escaping quotes. Applies to only CSV and tab-delimited files. |
|
| File compression; can be one of the following:
For GeoJSON and GeoJSONL files, using GZip results in a compressed single file with a .gz extension. No other compression options are currently available. |
|
| Type of file to export; can be one of the following:
For all file types except CSV, exactly one geo column (POINT, LINESTRING, POLYGON or MULTIPOLYGON) must be projected in the query. CSV exports can contain zero or any number of geo columns, exported as WKT strings. Export of array columns to shapefiles is not supported. |
|
| Either |
|
| A layer name for the geo layer in the file. If unspecified, the stem of the given filename is used, without path or extension. Applies to all file types except CSV. | Stem of the filename, if unspecified |
| A single-character string for terminating each line. Applies to only CSV and tab-delimited files. |
|
| A string pattern indicating that a field is NULL. Applies to only CSV and tab-delimited files. | An empty string, |
| A single-character string for quoting a column value. Applies to only CSV and tab-delimited files. |
|
| Either |
|
When using the COPY TO
command, you might encounter the following error:
To avoid this error, use the heavysql
command \cpu
to put your HEAVY.AI server in CPU mode before using the COPY TO
command. See Configuration.