-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[OUTFILE] Support INTO OUTFILE to export query result
#3584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
babec81
first
morningman-cmy b92794a
fe
morningman-cmy 6ac8693
fix bug
morningman c69bea3
fix
morningman-cmy f96a928
fix bug
morningman-cmy 8f3b8fd
add doc
morningman 5f886ce
add en doc
morningman 71d43c2
fix typo
morningman 155a3ca
add max file size
morningman b7e1150
add split file
morningman-cmy af61e17
fix by review
morningman-cmy 46df705
fix typo
morningman 6dc92c8
fix typo
morningman 9334a4b
fix by review
morningman-cmy 9f85149
modify syntax
morningman-cmy fbd9085
fix
morningman 88b18d7
fix bug
morningman-cmy cfea2c3
init returned_rows
morningman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #include "exec/parquet_writer.h" | ||
|
|
||
| #include <time.h> | ||
| #include <arrow/status.h> | ||
| #include <arrow/array.h> | ||
|
|
||
| #include "exec/file_writer.h" | ||
| #include "common/logging.h" | ||
| #include "gen_cpp/PaloBrokerService_types.h" | ||
| #include "gen_cpp/TPaloBrokerService.h" | ||
| #include "runtime/broker_mgr.h" | ||
| #include "runtime/client_cache.h" | ||
| #include "runtime/exec_env.h" | ||
| #include "runtime/tuple.h" | ||
| #include "runtime/descriptors.h" | ||
| #include "runtime/mem_pool.h" | ||
| #include "util/thrift_util.h" | ||
|
|
||
| namespace doris { | ||
|
|
||
| /// ParquetOutputStream | ||
| ParquetOutputStream::ParquetOutputStream(FileWriter* file_writer): _file_writer(file_writer) { | ||
| set_mode(arrow::io::FileMode::WRITE); | ||
| } | ||
|
|
||
| ParquetOutputStream::~ParquetOutputStream() { | ||
| Close(); | ||
| } | ||
|
|
||
| arrow::Status ParquetOutputStream::Write(const void* data, int64_t nbytes) { | ||
| size_t written_len = 0; | ||
| Status st = _file_writer->write(reinterpret_cast<const uint8_t*>(data), nbytes, &written_len); | ||
| if (!st.ok()) { | ||
| return arrow::Status::IOError(st.get_error_msg()); | ||
| } | ||
| _cur_pos += written_len; | ||
| return arrow::Status::OK(); | ||
| } | ||
|
|
||
| arrow::Status ParquetOutputStream::Tell(int64_t* position) const { | ||
| *position = _cur_pos; | ||
| return arrow::Status::OK(); | ||
| } | ||
|
|
||
| arrow::Status ParquetOutputStream::Close() { | ||
| Status st = _file_writer->close(); | ||
| if (!st.ok()) { | ||
kangkaisen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return arrow::Status::IOError(st.get_error_msg()); | ||
| } | ||
| _is_closed = true; | ||
| return arrow::Status::OK(); | ||
| } | ||
|
|
||
| /// ParquetWriterWrapper | ||
| ParquetWriterWrapper::ParquetWriterWrapper(FileWriter *file_writer, const std::vector<ExprContext*>& output_expr_ctxs) : | ||
| _output_expr_ctxs(output_expr_ctxs) { | ||
| // TODO(cmy): implement | ||
| _outstream = new ParquetOutputStream(file_writer); | ||
| } | ||
|
|
||
| Status ParquetWriterWrapper::write(const RowBatch& row_batch) { | ||
| // TODO(cmy): implement | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| void ParquetWriterWrapper::close() { | ||
| // TODO(cmy): implement | ||
| } | ||
|
|
||
| ParquetWriterWrapper::~ParquetWriterWrapper() { | ||
| close(); | ||
| } | ||
|
|
||
| } // end namespace | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| #include <string> | ||
| #include <map> | ||
| #include <arrow/api.h> | ||
| #include <arrow/io/api.h> | ||
| #include <arrow/io/file.h> | ||
| #include <arrow/io/interfaces.h> | ||
| #include <arrow/buffer.h> | ||
| #include <parquet/api/reader.h> | ||
| #include <parquet/api/writer.h> | ||
| #include <parquet/arrow/reader.h> | ||
| #include <parquet/arrow/writer.h> | ||
| #include <parquet/exception.h> | ||
|
|
||
| #include "common/status.h" | ||
| #include "gen_cpp/Types_types.h" | ||
| #include "gen_cpp/PaloBrokerService_types.h" | ||
| #include "gen_cpp/PlanNodes_types.h" | ||
|
|
||
| namespace doris { | ||
|
|
||
| class ExprContext; | ||
| class FileWriter; | ||
| class RowBatch; | ||
|
|
||
| class ParquetOutputStream : public arrow::io::OutputStream { | ||
| public: | ||
| ParquetOutputStream(FileWriter* file_writer); | ||
| virtual ~ParquetOutputStream(); | ||
|
|
||
| arrow::Status Write(const void* data, int64_t nbytes) override; | ||
| // return the current write position of the stream | ||
| arrow::Status Tell(int64_t* position) const override; | ||
| arrow::Status Close() override; | ||
|
|
||
| bool closed() const override { | ||
| return _is_closed; | ||
| } | ||
| private: | ||
| FileWriter* _file_writer; // not owned | ||
| int64_t _cur_pos; // current write position | ||
| bool _is_closed = false; | ||
| }; | ||
|
|
||
| // a wrapper of parquet output stream | ||
| class ParquetWriterWrapper { | ||
| public: | ||
| ParquetWriterWrapper(FileWriter *file_writer, const std::vector<ExprContext*>& output_expr_ctxs); | ||
| virtual ~ParquetWriterWrapper(); | ||
|
|
||
| Status write(const RowBatch& row_batch); | ||
|
|
||
| void close(); | ||
|
|
||
| private: | ||
| ParquetOutputStream* _outstream; | ||
| const std::vector<ExprContext*>& _output_expr_ctxs; | ||
| }; | ||
|
|
||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.