GitHub user jianqiao opened a pull request:
https://github.com/apache/incubator-quickstep/pull/291
Add "COPY TO" operator for exporting data from Quickstep.
This PR adds support for the "COPY TO" statement for exporting tables from
Quickstep. Two formats `TEXT` and `CSV` are supported.
The current available copy options are:
- `FORMAT`: Format of the output file, either `TEXT` or `CSV`.
- `DELIMITER`: Separator character of the fields.
- `HEADER`: Whether to add table header. For `CSV` format only.
- `QUOTE`: The quote character. For `CSV` format only.
- `ESCAPE_STRINGS`: Whether to escape special characters. For `TEXT` format
only.
- `NULL_STRING`: The string representation of the `NULL` value.
See the example queries and results
[here](https://github.com/apache/incubator-quickstep/blob/a036acb446f137fea263ae218ef12f337f5bc1a1/query_optimizer/tests/execution_generator/Copy.test).
Note that some convenient features are also provided:
- Export the result table from a query.
```
-- (1) --
COPY
SELECT x FROM r
TO 'data.txt';
-- (2) --
WITH s(v) AS (
SELECT MIN(y) FROM r GROUP BY x
)
COPY
SELECT AVG(v) FROM s
TO 'results.csv';
```
- Print to standard output/error stream, e.g.
```
-- (1) --
COPY r TO stdout;
-- (2) --
COPY
SELECT x FROM r
TO stderr;
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/incubator-quickstep copy-to
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-quickstep/pull/291.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #291
----
commit a036acb446f137fea263ae218ef12f337f5bc1a1
Author: Jianqiao Zhu <[email protected]>
Date: 2017-08-04T21:49:45Z
Add "COPY TO" operator for exporting data from Quickstep.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---