BePPPower commented on code in PR #13959:
URL: https://github.com/apache/doris/pull/13959#discussion_r1013716581


##########
be/src/service/internal_service.cpp:
##########
@@ -407,6 +410,78 @@ void 
PInternalServiceImpl::fetch_data(google::protobuf::RpcController* cntl_base
     _exec_env->result_mgr()->fetch_data(request->finst_id(), ctx);
 }
 
+void PInternalServiceImpl::fetch_table_schema(google::protobuf::RpcController* 
controller,
+                                              const PFetchTableSchemaRequest* 
request,
+                                              PFetchTableSchemaResult* result,
+                                              google::protobuf::Closure* done) 
{
+    VLOG_RPC << "fetch table schema";
+    brpc::ClosureGuard closure_guard(done);
+    TFileScanRange file_scan_range;
+    Status st = Status::OK();
+    {
+        const uint8_t* buf = (const 
uint8_t*)(request->file_scan_range().data());
+        uint32_t len = request->file_scan_range().size();
+        st = deserialize_thrift_msg(buf, &len, false, &file_scan_range);
+        if (!st.ok()) {
+            LOG(WARNING) << "fetch table schema failed, errmsg=" << 
st.get_error_msg();
+            st.to_protobuf(result->mutable_status());
+            return;
+        }
+    }
+
+    if (file_scan_range.__isset.ranges == false) {
+        st = Status::InternalError("can not get TFileRangeDesc.");
+        st.to_protobuf(result->mutable_status());
+        return;
+    }
+    if (file_scan_range.__isset.params == false) {
+        st = Status::InternalError("can not get TFileScanRangeParams.");
+        st.to_protobuf(result->mutable_status());
+        return;
+    }
+    const TFileRangeDesc& range = file_scan_range.ranges.at(0);
+    const TFileScanRangeParams& params = file_scan_range.params;
+    // file_slots is no use
+    std::vector<SlotDescriptor*> file_slots;
+    std::unique_ptr<vectorized::GenericReader> reader(nullptr);
+    std::unique_ptr<RuntimeProfile> profile(new 
RuntimeProfile("FetchTableSchema"));
+    switch (params.format_type) {
+    case TFileFormatType::FORMAT_CSV_PLAIN:
+    case TFileFormatType::FORMAT_CSV_GZ:
+    case TFileFormatType::FORMAT_CSV_BZ2:
+    case TFileFormatType::FORMAT_CSV_LZ4FRAME:
+    case TFileFormatType::FORMAT_CSV_LZOP:
+    case TFileFormatType::FORMAT_CSV_DEFLATE: {

Review Comment:
   Parquet and ORC will be added after implementing `get_parsered_schema` 
method of  ParquetReader and OrcReader.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to