Skip to content

Commit

Permalink
Update COPY documentation to reflect cahnges (#9754)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb authored Mar 29, 2024
1 parent 2d02329 commit 2956ec2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions docs/source/user-guide/sql/dml.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ and modifying data in tables.
## COPY

Copies the contents of a table or query to file(s). Supported file
formats are `parquet`, `csv`, and `json` and can be inferred based on
filename if writing to a single file.
formats are `parquet`, `csv`, `json`, and `arrow`.

<pre>
COPY { <i><b>table_name</i></b> | <i><b>query</i></b> } TO '<i><b>file_name</i></b>' [ ( <i><b>option</i></b> [, ... ] ) ]
COPY { <i><b>table_name</i></b> | <i><b>query</i></b> }
TO '<i><b>file_name</i></b>'
[ STORED AS <i><b>format</i></b> ]
[ PARTITIONED BY <i><b>column_name</i></b> [, ...] ]
[ OPTIONS( <i><b>option</i></b> [, ... ] ) ]
</pre>

For a detailed list of valid OPTIONS, see [Write Options](write_options).
Expand Down Expand Up @@ -61,7 +64,7 @@ Copy the contents of `source_table` to multiple directories
of hive-style partitioned parquet files:

```sql
> COPY source_table TO 'dir_name' (FORMAT parquet, partition_by 'column1, column2');
> COPY source_table TO 'dir_name' STORED AS parquet, PARTITIONED BY (column1, column2);
+-------+
| count |
+-------+
Expand All @@ -74,14 +77,20 @@ results (maintaining the order) to a parquet file named
`output.parquet` with a maximum parquet row group size of 10MB:

```sql
> COPY (SELECT * from source ORDER BY time) TO 'output.parquet' (ROW_GROUP_LIMIT_BYTES 10000000);
> COPY (SELECT * from source ORDER BY time) TO 'output.parquet' OPTIONS (MAX_ROW_GROUP_SIZE 10000000);
+-------+
| count |
+-------+
| 2 |
+-------+
```

The output format is determined by the first match of the following rules:

1. Value of `STORED AS`
2. Value of the `OPTION (FORMAT ..)`
3. Filename extension (e.g. `foo.parquet` implies `PARQUET` format)

## INSERT

Insert values into a table.
Expand Down

0 comments on commit 2956ec2

Please sign in to comment.