## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> There's no issue for this, just some simple text fixes. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> While "the the" *can* be grammatically correct, in these instances it was not. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> "the the" -> "the" ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Not at as such, no. ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> Yes, in both code docs and in the website.
3.6 KiB
DML
DML stands for "Data Manipulation Language" and relates to inserting and modifying data in tables.
COPY
Copies the contents of a table or query to file(s). Supported file
formats are parquet, csv, json, and arrow.
COPY { table_name | query }
TO 'file_name'
[ STORED AS format ]
[ PARTITIONED BY column_name [, ...] ]
[ OPTIONS( option [, ... ] ) ]
STORED AS specifies the file format the COPY command will write. If this
clause is not specified, it will be inferred from the file extension if possible.
PARTITIONED BY specifies the columns to use for partitioning the output files into
separate hive-style directories. By default, columns used in PARTITIONED BY will be removed
from the output format. If you want to keep the columns, you should provide the option
execution.keep_partition_by_columns true. execution.keep_partition_by_columns flag can also
be enabled through ExecutionOptions within SessionConfig.
The output format is determined by the first match of the following rules:
- Value of
STORED AS - Filename extension (e.g.
foo.parquetimpliesPARQUETformat)
For a detailed list of valid OPTIONS, see Format Options.
Examples
Copy the contents of source_table to file_name.json in JSON format:
> COPY source_table TO 'file_name.json';
+-------+
| count |
+-------+
| 2 |
+-------+
Copy the contents of source_table to one or more Parquet formatted
files in the dir_name directory:
> COPY source_table TO 'dir_name' STORED AS PARQUET;
+-------+
| count |
+-------+
| 2 |
+-------+
Copy the contents of source_table to multiple directories
of hive-style partitioned parquet files:
> COPY source_table TO 'dir_name' STORED AS parquet, PARTITIONED BY (column1, column2);
+-------+
| count |
+-------+
| 2 |
+-------+
If the data contains values of x and y in column1 and only a in
column2, output files will appear in the following directory structure:
dir_name/
column1=x/
column2=a/
<file>.parquet
<file>.parquet
...
column1=y/
column2=a/
<file>.parquet
<file>.parquet
...
Run the query SELECT * from source ORDER BY time and write the
results (maintaining the order) to a parquet file named
output.parquet with a maximum parquet row group size of 10MB:
> COPY (SELECT * from source ORDER BY time) TO 'output.parquet' OPTIONS (MAX_ROW_GROUP_SIZE 10000000);
+-------+
| count |
+-------+
| 2 |
+-------+
INSERT
Examples
Insert values into a table.
INSERT INTO table_name { VALUES ( expression [, ...] ) [, ...] | query }
> INSERT INTO target_table VALUES (1, 'Foo'), (2, 'Bar');
+-------+
| count |
+-------+
| 2 |
+-------+