From 791f8fee49bd392cbd95efafbafe9aaec3dccca4 Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Thu, 4 Jun 2020 10:35:32 +0800 Subject: [PATCH] [Bug][Outfile] Fix bug that column separater is missing in output file. (#3765) When output result of a query using `OUTFILE` statement, is some of output column is null, then then following column separator is missing. --- be/src/runtime/file_result_writer.cpp | 3 +++ docs/en/administrator-guide/outfile.md | 2 ++ docs/zh-CN/administrator-guide/outfile.md | 2 ++ 3 files changed, 7 insertions(+) diff --git a/be/src/runtime/file_result_writer.cpp b/be/src/runtime/file_result_writer.cpp index 2cc6102d81..8d777e6f1d 100644 --- a/be/src/runtime/file_result_writer.cpp +++ b/be/src/runtime/file_result_writer.cpp @@ -149,6 +149,9 @@ Status FileResultWriter::_write_one_row_as_csv(TupleRow* row) { if (item == nullptr) { _plain_text_outstream << NULL_IN_CSV; + if (i < num_columns - 1) { + _plain_text_outstream << _file_opts->column_separator; + } continue; } diff --git a/docs/en/administrator-guide/outfile.md b/docs/en/administrator-guide/outfile.md index 77a535d8e7..f0e93e73ed 100644 --- a/docs/en/administrator-guide/outfile.md +++ b/docs/en/administrator-guide/outfile.md @@ -184,3 +184,5 @@ mysql> SELECT * FROM tbl INTO OUTFILE ... * The timeout of the export command is the same as the timeout of the query. It can be set by `SET query_timeout = xxx`. * For empty result query, there will be an empty file. * File spliting will ensure that a row of data is stored in a single file. Therefore, the size of the file is not strictly equal to `max_file_size`. +* For functions whose output is invisible characters, such as BITMAP and HLL types, the output is `\N`, which is NULL. +* At present, the output type of some geo functions, such as `ST_Point` is VARCHAR, but the actual output value is an encoded binary character. Currently these functions will output garbled characters. For geo functions, use `ST_AsText` for output. diff --git a/docs/zh-CN/administrator-guide/outfile.md b/docs/zh-CN/administrator-guide/outfile.md index 7a11aca301..5bc87bb8cf 100644 --- a/docs/zh-CN/administrator-guide/outfile.md +++ b/docs/zh-CN/administrator-guide/outfile.md @@ -180,3 +180,5 @@ mysql> SELECT * FROM tbl INTO OUTFILE ... * 导出命令的超时时间同查询的超时时间。可以通过 `SET query_timeout=xxx` 进行设置。 * 对于结果集为空的查询,依然会产生一个大小为0的文件。 * 文件切分会保证一行数据完整的存储在单一文件中。因此文件的大小并不严格等于 `max_file_size`。 +* 对于部分输出为非可见字符的函数,如 BITMAP、HLL 类型,输出为 `\N`,即 NULL。 +* 目前部分地理信息函数,如 `ST_Point` 的输出类型为 VARCHAR,但实际输出值为经过编码的二进制字符。当前这些函数会输出乱码。对于地理函数,请使用 `ST_AsText` 进行输出。